Skip to content

Commit

Permalink
fabric: Define new FI_DUP control code
Browse files Browse the repository at this point in the history
This will be used to duplicate an fid_nic structure.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
  • Loading branch information
shefty committed Sep 25, 2018
1 parent 84fdc85 commit ee5ea4c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/rdma/fabric.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ enum {
FI_CANCEL_WORK, /* struct fi_deferred_work */
FI_FLUSH_WORK, /* NULL */
FI_REFRESH, /* mr: fi_mr_modify */
FI_DUP, /* struct fid ** */
};

static inline int fi_control(struct fid *fid, int command, void *arg)
Expand Down
22 changes: 22 additions & 0 deletions src/fabric.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,23 @@ int ofi_nic_close(struct fid *fid)
return 0;
}

int ofi_nic_control(struct fid *fid, int command, void *arg)
{
struct fid_nic **nic = (struct fid_nic **) arg;

switch(command) {
case FI_DUP:
*nic = ofi_nic_dup(*nic);
return *nic ? 0 : -FI_ENOMEM;
default:
return -FI_ENOSYS;
}
}

struct fi_ops default_nic_ops = {
.size = sizeof(struct fi_ops),
.close = ofi_nic_close,
.control = ofi_nic_control,
};

static int ofi_dup_dev_attr(const struct fi_device_attr *attr,
Expand Down Expand Up @@ -880,6 +894,7 @@ __attribute__((visibility ("default"),EXTERNALLY_VISIBLE))
struct fi_info *DEFAULT_SYMVER_PRE(fi_dupinfo)(const struct fi_info *info)
{
struct fi_info *dup;
struct fid *handle;

if (!info)
return ofi_allocinfo_internal();
Expand Down Expand Up @@ -967,6 +982,13 @@ struct fi_info *DEFAULT_SYMVER_PRE(fi_dupinfo)(const struct fi_info *info)
goto fail;
}
}

if (info->handle && info->handle->ops && info->handle->ops->control) {
handle = info->handle;
if (fi_control(handle, FI_DUP, &handle))
goto fail;
dup->handle = handle;
}
return dup;

fail:
Expand Down

0 comments on commit ee5ea4c

Please sign in to comment.