InfiniBand and Remote DMA (RDMA) Interfaces¶
Introduction and Overview¶
TBD
InfiniBand core interfaces¶
-
struct iwpm_nlmsg_request *iwpm_get_nlmsg_request(__u32 nlmsg_seq, u8 nl_client, gfp_t gfp)¶
Allocate and initialize netlink message request
Parameters
__u32 nlmsg_seqSequence number of the netlink message
u8 nl_clientThe index of the netlink client
gfp_t gfpIndicates how the memory for the request should be allocated
Description
Returns the newly allocated netlink request object if successful, otherwise returns NULL
Parameters
struct kref *krefHolds reference of netlink message request
-
struct iwpm_nlmsg_request *iwpm_find_nlmsg_request(__u32 echo_seq)¶
Find netlink message request in the request list
Parameters
__u32 echo_seqSequence number of the netlink request to find
Description
Returns the found netlink message request, if not found, returns NULL
-
int iwpm_wait_complete_req(struct iwpm_nlmsg_request *nlmsg_request)¶
Block while servicing the netlink request
Parameters
struct iwpm_nlmsg_request *nlmsg_requestNetlink message request to service
Description
Wakes up, after the request is completed or expired Returns 0 if the request is complete without error
-
int iwpm_get_nlmsg_seq(void)¶
Get the sequence number for a netlink message to send to the port mapper
Parameters
voidno arguments
Description
Returns the sequence number for the netlink message.
-
void iwpm_add_remote_info(struct iwpm_remote_info *reminfo)¶
Add remote address info of the connecting peer to the remote info hash table
Parameters
struct iwpm_remote_info *reminfoThe remote info to be added
-
u32 iwpm_check_registration(u8 nl_client, u32 reg)¶
Check if the client registration matches the given one
Parameters
u8 nl_clientThe index of the netlink client
u32 regThe given registration type to compare with
Description
Call iwpm_register_pid() to register a client Returns true if the client registration matches reg, otherwise returns false
-
void iwpm_set_registration(u8 nl_client, u32 reg)¶
Set the client registration
Parameters
u8 nl_clientThe index of the netlink client
u32 regRegistration type to set
-
u32 iwpm_get_registration(u8 nl_client)¶
Get the client registration
Parameters
u8 nl_clientThe index of the netlink client
Description
Returns the client registration type
-
int iwpm_send_mapinfo(u8 nl_client, int iwpm_pid)¶
Send local and mapped IPv4/IPv6 address info of a client to the user space port mapper
Parameters
u8 nl_clientThe index of the netlink client
int iwpm_pidThe pid of the user space port mapper
Description
If successful, returns the number of sent mapping info records
-
int iwpm_mapinfo_available(void)¶
Check if any mapping info records is available in the hash table
Parameters
voidno arguments
Description
Returns 1 if mapping information is available, otherwise returns 0
-
int iwpm_compare_sockaddr(struct sockaddr_storage *a_sockaddr, struct sockaddr_storage *b_sockaddr)¶
Compare two sockaddr storage structs
Parameters
struct sockaddr_storage *a_sockaddrfirst sockaddr to compare
struct sockaddr_storage *b_sockaddrsecond sockaddr to compare
Return
0 if they are holding the same ip/tcp address info, otherwise returns 1
-
int iwpm_validate_nlmsg_attr(struct nlattr *nltb[], int nla_count)¶
Check for NULL netlink attributes
Parameters
struct nlattr *nltb[]Holds address of each netlink message attributes
int nla_countNumber of netlink message attributes
Description
Returns error if any of the nla_count attributes is NULL
-
struct sk_buff *iwpm_create_nlmsg(u32 nl_op, struct nlmsghdr **nlh, int nl_client)¶
Allocate skb and form a netlink message
Parameters
u32 nl_opNetlink message opcode
struct nlmsghdr **nlhHolds address of the netlink message header in skb
int nl_clientThe index of the netlink client
Description
Returns the newly allcated skb, or NULL if the tailroom of the skb is insufficient to store the message header and payload
-
int iwpm_parse_nlmsg(struct netlink_callback *cb, int policy_max, const struct nla_policy *nlmsg_policy, struct nlattr *nltb[], const char *msg_type)¶
Validate and parse the received netlink message
Parameters
struct netlink_callback *cbNetlink callback structure
int policy_maxMaximum attribute type to be expected
const struct nla_policy *nlmsg_policyValidation policy
struct nlattr *nltb[]Array to store policy_max parsed elements
const char *msg_typeType of netlink message
Description
Returns 0 on success or a negative error code
-
void iwpm_print_sockaddr(struct sockaddr_storage *sockaddr, char *msg)¶
Print IPv4/IPv6 address and TCP port
Parameters
struct sockaddr_storage *sockaddrSocket address to print
char *msgMessage to print
-
int iwpm_send_hello(u8 nl_client, int iwpm_pid, u16 abi_version)¶
Send hello response to iwpmd
Parameters
u8 nl_clientThe index of the netlink client
int iwpm_pidThe pid of the user space port mapper
u16 abi_versionThe kernel’s abi_version
Description
Returns 0 on success or a negative error code
-
int ib_process_cq_direct(struct ib_cq *cq, int budget)¶
process a CQ in caller context
Parameters
struct ib_cq *cqCQ to process
int budgetnumber of CQEs to poll for
Description
This function is used to process all outstanding CQ entries. It does not offload CQ processing to a different context and does not ask for completion interrupts from the HCA. Using direct processing on CQ with non IB_POLL_DIRECT type may trigger concurrent processing.
Note
do not pass -1 as budget unless it is guaranteed that the number
of completions that will be processed is small.
-
struct ib_cq *__ib_alloc_cq(struct ib_device *dev, void *private, int nr_cqe, int comp_vector, enum ib_poll_context poll_ctx, const char *caller)¶
allocate a completion queue
Parameters
struct ib_device *devdevice to allocate the CQ for
void *privatedriver private data, accessible from cq->cq_context
int nr_cqenumber of CQEs to allocate
int comp_vectorHCA completion vectors for this CQ
enum ib_poll_context poll_ctxcontext to poll the CQ from.
const char *callermodule owner name.
Description
This is the proper interface to allocate a CQ for in-kernel users. A CQ allocated with this interface will automatically be polled from the specified context. The ULP must use wr->wr_cqe instead of wr->wr_id to use this CQ abstraction.
-
struct ib_cq *__ib_alloc_cq_any(struct ib_device *dev, void *private, int nr_cqe, enum ib_poll_context poll_ctx, const char *caller)¶
allocate a completion queue
Parameters
struct ib_device *devdevice to allocate the CQ for
void *privatedriver private data, accessible from cq->cq_context
int nr_cqenumber of CQEs to allocate
enum ib_poll_context poll_ctxcontext to poll the CQ from
const char *callermodule owner name
Description
Attempt to spread ULP Completion Queues over each device’s interrupt vectors. A simple best-effort mechanism is used.
-
void ib_free_cq(struct ib_cq *cq)¶
free a completion queue
Parameters
struct ib_cq *cqcompletion queue to free.
-
struct ib_cq *ib_cq_pool_get(struct ib_device *dev, unsigned int nr_cqe, int comp_vector_hint, enum ib_poll_context poll_ctx)¶
Find the least used completion queue that matches a given cpu hint (or least used for wild card affinity) and fits nr_cqe.
Parameters
struct ib_device *devrdma device
unsigned int nr_cqenumber of needed cqe entries
int comp_vector_hintcompletion vector hint (-1) for the driver to assign a comp vector based on internal counter
enum ib_poll_context poll_ctxcq polling context
Description
Finds a cq that satisfies comp_vector_hint and nr_cqe requirements and claim entries in it for us. In case there is no available cq, allocate a new cq with the requirements and add it to the device pool. IB_POLL_DIRECT cannot be used for shared cqs so it is not a valid value for poll_ctx.
-
void ib_cq_pool_put(struct ib_cq *cq, unsigned int nr_cqe)¶
Return a CQ taken from a shared pool.
Parameters
struct ib_cq *cqThe CQ to return.
unsigned int nr_cqeThe max number of cqes that the user had requested.
-
int ib_cm_listen(struct ib_cm_id *cm_id, __be64 service_id)¶
Initiates listening on the specified service ID for connection and service ID resolution requests.
Parameters
struct ib_cm_id *cm_idConnection identifier associated with the listen request.
__be64 service_idService identifier matched against incoming connection and service ID resolution requests. The service ID should be specified network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will assign a service ID to the caller.
-
struct ib_cm_id *ib_cm_insert_listen(struct ib_device *device, ib_cm_handler cm_handler, __be64 service_id)¶
Create a new listening ib_cm_id and listen on the given service ID.
Parameters
struct ib_device *deviceDevice associated with the cm_id. All related communication will be associated with the specified device.
ib_cm_handler cm_handlerCallback invoked to notify the user of CM events.
__be64 service_idService identifier matched against incoming connection and service ID resolution requests. The service ID should be specified network-byte order. If set to IB_CM_ASSIGN_SERVICE_ID, the CM will assign a service ID to the caller.
Description
If there’s an existing ID listening on that same device and service ID, return it.
Callers should call ib_destroy_cm_id when done with the listener ID.
-
int rdma_rw_ctx_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num, struct scatterlist *sg, u32 sg_cnt, u32 sg_offset, u64 remote_addr, u32 rkey, enum dma_data_direction dir)¶
initialize a RDMA READ/WRITE context
Parameters
struct rdma_rw_ctx *ctxcontext to initialize
struct ib_qp *qpqueue pair to operate on
u32 port_numport num to which the connection is bound
struct scatterlist *sgscatterlist to READ/WRITE from/to
u32 sg_cntnumber of entries in sg
u32 sg_offsetcurrent byte offset into sg
u64 remote_addrremote address to read/write (relative to rkey)
u32 rkeyremote key to operate on
enum dma_data_direction dirDMA_TO_DEVICEfor RDMA WRITE,DMA_FROM_DEVICEfor RDMA READ
Description
Returns the number of WQEs that will be needed on the workqueue if successful, or a negative error code.
-
int rdma_rw_ctx_signature_init(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num, struct scatterlist *sg, u32 sg_cnt, struct scatterlist *prot_sg, u32 prot_sg_cnt, struct ib_sig_attrs *sig_attrs, u64 remote_addr, u32 rkey, enum dma_data_direction dir)¶
initialize a RW context with signature offload
Parameters
struct rdma_rw_ctx *ctxcontext to initialize
struct ib_qp *qpqueue pair to operate on
u32 port_numport num to which the connection is bound
struct scatterlist *sgscatterlist to READ/WRITE from/to
u32 sg_cntnumber of entries in sg
struct scatterlist *prot_sgscatterlist to READ/WRITE protection information from/to
u32 prot_sg_cntnumber of entries in prot_sg
struct ib_sig_attrs *sig_attrssignature offloading algorithms
u64 remote_addrremote address to read/write (relative to rkey)
u32 rkeyremote key to operate on
enum dma_data_direction dirDMA_TO_DEVICEfor RDMA WRITE,DMA_FROM_DEVICEfor RDMA READ
Description
Returns the number of WQEs that will be needed on the workqueue if successful, or a negative error code.
-
struct ib_send_wr *rdma_rw_ctx_wrs(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num, struct ib_cqe *cqe, struct ib_send_wr *chain_wr)¶
return chain of WRs for a RDMA READ or WRITE operation
Parameters
struct rdma_rw_ctx *ctxcontext to operate on
struct ib_qp *qpqueue pair to operate on
u32 port_numport num to which the connection is bound
struct ib_cqe *cqecompletion queue entry for the last WR
struct ib_send_wr *chain_wrWR to append to the posted chain
Description
Return the WR chain for the set of RDMA READ/WRITE operations described by ctx, as well as any memory registration operations needed. If chain_wr is non-NULL the WR it points to will be appended to the chain of WRs posted. If chain_wr is not set cqe must be set so that the caller gets a completion notification.
-
int rdma_rw_ctx_post(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num, struct ib_cqe *cqe, struct ib_send_wr *chain_wr)¶
post a RDMA READ or RDMA WRITE operation
Parameters
struct rdma_rw_ctx *ctxcontext to operate on
struct ib_qp *qpqueue pair to operate on
u32 port_numport num to which the connection is bound
struct ib_cqe *cqecompletion queue entry for the last WR
struct ib_send_wr *chain_wrWR to append to the posted chain
Description
Post the set of RDMA READ/WRITE operations described by ctx, as well as any memory registration operations needed. If chain_wr is non-NULL the WR it points to will be appended to the chain of WRs posted. If chain_wr is not set cqe must be set so that the caller gets a completion notification.
-
void rdma_rw_ctx_destroy(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num, struct scatterlist *sg, u32 sg_cnt, enum dma_data_direction dir)¶
release all resources allocated by rdma_rw_ctx_init
Parameters
struct rdma_rw_ctx *ctxcontext to release
struct ib_qp *qpqueue pair to operate on
u32 port_numport num to which the connection is bound
struct scatterlist *sgscatterlist that was used for the READ/WRITE
u32 sg_cntnumber of entries in sg
enum dma_data_direction dirDMA_TO_DEVICEfor RDMA WRITE,DMA_FROM_DEVICEfor RDMA READ
-
void rdma_rw_ctx_destroy_signature(struct rdma_rw_ctx *ctx, struct ib_qp *qp, u32 port_num, struct scatterlist *sg, u32 sg_cnt, struct scatterlist *prot_sg, u32 prot_sg_cnt, enum dma_data_direction dir)¶
release all resources allocated by rdma_rw_ctx_signature_init
Parameters
struct rdma_rw_ctx *ctxcontext to release
struct ib_qp *qpqueue pair to operate on
u32 port_numport num to which the connection is bound
struct scatterlist *sgscatterlist that was used for the READ/WRITE
u32 sg_cntnumber of entries in sg
struct scatterlist *prot_sgscatterlist that was used for the READ/WRITE of the PI
u32 prot_sg_cntnumber of entries in prot_sg
enum dma_data_direction dirDMA_TO_DEVICEfor RDMA WRITE,DMA_FROM_DEVICEfor RDMA READ
-
unsigned int rdma_rw_mr_factor(struct ib_device *device, u32 port_num, unsigned int maxpages)¶
return number of MRs required for a payload
Parameters
struct ib_device *devicedevice handling the connection
u32 port_numport num to which the connection is bound
unsigned int maxpagesmaximum payload pages per rdma_rw_ctx
Description
Returns the number of MRs the device requires to move maxpayload bytes. The returned value is used during transport creation to compute max_rdma_ctxts and the size of the transport’s Send and Send Completion Queues.
-
bool rdma_dev_access_netns(const struct ib_device *dev, const struct net *net)¶
Return whether an rdma device can be accessed from a specified net namespace or not.
Parameters
const struct ib_device *devPointer to rdma device which needs to be checked
const struct net *netPointer to net namesapce for which access to be checked
Description
When the rdma device is in shared mode, it ignores the net namespace. When the rdma device is exclusive to a net namespace, rdma device net namespace is checked against the specified one.
-
void ib_device_put(struct ib_device *device)¶
Release IB device reference
Parameters
struct ib_device *devicedevice whose reference to be released
Description
ib_device_put() releases reference to the IB device to allow it to be
unregistered and eventually free.
-
struct ib_device *ib_device_get_by_name(const char *name, enum rdma_driver_id driver_id)¶
Find an IB device by name
Parameters
const char *nameThe name to look for
enum rdma_driver_id driver_idThe driver ID that must match (RDMA_DRIVER_UNKNOWN matches all)
Description
Find and hold an ib_device by its name. The caller must call
ib_device_put() on the returned pointer.
-
struct ib_device *_ib_alloc_device(size_t size)¶
allocate an IB device struct
Parameters
size_t sizesize of structure to allocate
Description
Low-level drivers should use ib_alloc_device() to allocate struct
ib_device. size is the size of the structure to be allocated,
including any private data used by the low-level driver.
ib_dealloc_device() must be used to free structures allocated with
ib_alloc_device().
-
void ib_dealloc_device(struct ib_device *device)¶
free an IB device struct
Parameters
struct ib_device *devicestructure to free
Description
Free a structure allocated with ib_alloc_device().
-
const struct ib_port_immutable *ib_port_immutable_read(struct ib_device *dev, unsigned int port)¶
Read rdma port’s immutable data
Parameters
struct ib_device *devIB device
unsigned int portport number whose immutable data to read. It starts with index 1 and valid upto including rdma_end_port().
-
int ib_register_device(struct ib_device *device, const char *name, struct device *dma_device)¶
Register an IB device with IB core
Parameters
struct ib_device *deviceDevice to register
const char *nameunique string device name. This may include a ‘%’ which will cause a unique index to be added to the passed device name.
struct device *dma_devicepointer to a DMA-capable device. If
NULL, then the IB device will be used. In this case the caller should fully setup the ibdev for DMA. This usually means using dma_virt_ops.
Description
Low-level drivers use ib_register_device() to register their
devices with the IB core. All registered clients will receive a
callback for each device that is added. device must be allocated
with ib_alloc_device().
If the driver uses ops.dealloc_driver and calls any ib_unregister_device()
asynchronously then the device pointer may become freed as soon as this
function returns.
-
void ib_unregister_device(struct ib_device *ib_dev)¶
Unregister an IB device
Parameters
struct ib_device *ib_devThe device to unregister
Description
Unregister an IB device. All clients will receive a remove callback.
Callers should call this routine only once, and protect against races with
registration. Typically it should only be called as part of a remove
callback in an implementation of driver core’s struct device_driver and
related.
If ops.dealloc_driver is used then ib_dev will be freed upon return from this function.
-
void ib_unregister_device_and_put(struct ib_device *ib_dev)¶
Unregister a device while holding a ‘get’
Parameters
struct ib_device *ib_devThe device to unregister
Description
This is the same as ib_unregister_device(), except it includes an internal
ib_device_put() that should match a ‘get’ obtained by the caller.
It is safe to call this routine concurrently from multiple threads while holding the ‘get’. When the function returns the device is fully unregistered.
Drivers using this flow MUST use the driver_unregister callback to clean up their resources associated with the device and dealloc it.
-
void ib_unregister_driver(enum rdma_driver_id driver_id)¶
Unregister all IB devices for a driver
Parameters
enum rdma_driver_id driver_idThe driver to unregister
Description
This implements a fence for device unregistration. It only returns once all devices associated with the driver_id have fully completed their unregistration and returned from ib_unregister_device*().
If device’s are not yet unregistered it goes ahead and starts unregistering them.
This does not block creation of new devices with the given driver_id, that is the responsibility of the caller.
-
void ib_unregister_device_queued(struct ib_device *ib_dev)¶
Unregister a device using a work queue
Parameters
struct ib_device *ib_devThe device to unregister
Description
This schedules an asynchronous unregistration using a WQ for the device. A driver should use this to avoid holding locks while doing unregistration, such as holding the RTNL lock.
Drivers using this API must use ib_unregister_driver before module unload to ensure that all scheduled unregistrations have completed.
-
int ib_register_client(struct ib_client *client)¶
Register an IB client
Parameters
struct ib_client *clientClient to register
Description
Upper level users of the IB drivers can use ib_register_client() to
register callbacks for IB device addition and removal. When an IB
device is added, each registered client’s add method will be called
(in the order the clients were registered), and when a device is
removed, each client’s remove method will be called (in the reverse
order that clients were registered). In addition, when
ib_register_client() is called, the client will receive an add
callback for all devices already registered.
-
void ib_unregister_client(struct ib_client *client)¶
Unregister an IB client
Parameters
struct ib_client *clientClient to unregister
Description
Upper level users use ib_unregister_client() to remove their client
registration. When ib_unregister_client() is called, the client
will receive a remove callback for each IB device still registered.
This is a full fence, once it returns no client callbacks will be called, or are running in another thread.
-
void ib_set_client_data(struct ib_device *device, struct ib_client *client, void *data)¶
Set IB client context
Parameters
struct ib_device *deviceDevice to set context for
struct ib_client *clientClient to set context for
void *dataContext to set
Description
ib_set_client_data() sets client context data that can be retrieved with
ib_get_client_data(). This can only be called while the client is
registered to the device, once the ib_client remove() callback returns this
cannot be called.
-
void ib_register_event_handler(struct ib_event_handler *event_handler)¶
Register an IB event handler
Parameters
struct ib_event_handler *event_handlerHandler to register
Description
ib_register_event_handler() registers an event handler that will be
called back when asynchronous IB events occur (as defined in
chapter 11 of the InfiniBand Architecture Specification). This
callback occurs in workqueue context.
-
void ib_unregister_event_handler(struct ib_event_handler *event_handler)¶
Unregister an event handler
Parameters
struct ib_event_handler *event_handlerHandler to unregister
Description
Unregister an event handler registered with
ib_register_event_handler().
-
int ib_query_port(struct ib_device *device, u32 port_num, struct ib_port_attr *port_attr)¶
Query IB port attributes
Parameters
struct ib_device *deviceDevice to query
u32 port_numPort number to query
struct ib_port_attr *port_attrPort attributes
Description
ib_query_port() returns the attributes of a port through the
port_attr pointer.
-
int ib_device_set_netdev(struct ib_device *ib_dev, struct net_device *ndev, u32 port)¶
Associate the ib_dev with an underlying net_device
Parameters
struct ib_device *ib_devDevice to modify
struct net_device *ndevnet_device to affiliate, may be NULL
u32 portIB port the net_device is connected to
Description
Drivers should use this to link the ib_device to a netdev so the netdev shows up in interfaces like ib_enum_roce_netdev. Only one netdev may be affiliated with any port.
The caller must ensure that the given ndev is not unregistered or
unregistering, and that either the ib_device is unregistered or
ib_device_set_netdev() is called with NULL when the ndev sends a
NETDEV_UNREGISTER event.
-
int ib_query_netdev_port(struct ib_device *ibdev, struct net_device *ndev, u32 *port)¶
Query the port number of a net_device associated with an ibdev
Parameters
struct ib_device *ibdevIB device
struct net_device *ndevNetwork device
u32 *portIB port the net_device is connected to
-
struct ib_device *ib_device_get_by_netdev(struct net_device *ndev, enum rdma_driver_id driver_id)¶
Find an IB device associated with a netdev
Parameters
struct net_device *ndevnetdev to locate
enum rdma_driver_id driver_idThe driver ID that must match (RDMA_DRIVER_UNKNOWN matches all)
Description
Find and hold an ib_device that is associated with a netdev via
ib_device_set_netdev(). The caller must call ib_device_put() on the
returned pointer.
-
int ib_query_pkey(struct ib_device *device, u32 port_num, u16 index, u16 *pkey)¶
Get P_Key table entry
Parameters
struct ib_device *deviceDevice to query
u32 port_numPort number to query
u16 indexP_Key table index to query
u16 *pkeyReturned P_Key
Description
ib_query_pkey() fetches the specified P_Key table entry.
-
int ib_modify_device(struct ib_device *device, int device_modify_mask, struct ib_device_modify *device_modify)¶
Change IB device attributes
Parameters
struct ib_device *deviceDevice to modify
int device_modify_maskMask of attributes to change
struct ib_device_modify *device_modifyNew attribute values
Description
ib_modify_device() changes a device’s attributes as specified by
the device_modify_mask and device_modify structure.
-
int ib_modify_port(struct ib_device *device, u32 port_num, int port_modify_mask, struct ib_port_modify *port_modify)¶
Modifies the attributes for the specified port.
Parameters
struct ib_device *deviceThe device to modify.
u32 port_numThe number of the port to modify.
int port_modify_maskMask used to specify which attributes of the port to change.
struct ib_port_modify *port_modifyNew attribute values for the port.
Description
ib_modify_port() changes a port’s attributes as specified by the
port_modify_mask and port_modify structure.
-
int ib_find_gid(struct ib_device *device, union ib_gid *gid, u32 *port_num, u16 *index)¶
Returns the port number and GID table index where a specified GID value occurs. Its searches only for IB link layer.
Parameters
struct ib_device *deviceThe device to query.
union ib_gid *gidThe GID value to search for.
u32 *port_numThe port number of the device where the GID value was found.
u16 *indexThe index into the GID table where the GID was found. This parameter may be NULL.
-
int ib_find_pkey(struct ib_device *device, u32 port_num, u16 pkey, u16 *index)¶
Returns the PKey table index where a specified PKey value occurs.
Parameters
struct ib_device *deviceThe device to query.
u32 port_numThe port number of the device to search for the PKey.
u16 pkeyThe PKey value to search for.
u16 *indexThe index into the PKey table where the PKey was found.
-
struct net_device *ib_get_net_dev_by_params(struct ib_device *dev, u32 port, u16 pkey, const union ib_gid *gid, const struct sockaddr *addr)¶
Return the appropriate net_dev for a received CM request
Parameters
struct ib_device *devAn RDMA device on which the request has been received.
u32 portPort number on the RDMA device.
u16 pkeyThe Pkey the request came on.
const union ib_gid *gidA GID that the net_dev uses to communicate.
const struct sockaddr *addrContains the IP address that the request specified as its destination.
-
struct ib_pd *__ib_alloc_pd(struct ib_device *device, unsigned int flags, const char *caller)¶
Allocates an unused protection domain.
Parameters
struct ib_device *deviceThe device on which to allocate the protection domain.
unsigned int flagsprotection domain flags
const char *callercaller’s build-time module name
Description
A protection domain object provides an association between QPs, shared receive queues, address handles, memory regions, and memory windows.
Every PD has a local_dma_lkey which can be used as the lkey value for local memory operations.
-
int ib_dealloc_pd_user(struct ib_pd *pd, struct ib_udata *udata)¶
Deallocates a protection domain.
Parameters
struct ib_pd *pdThe protection domain to deallocate.
struct ib_udata *udataValid user data or NULL for kernel object
Description
It is an error to call this function while any resources in the pd still exist. The caller is responsible to synchronously destroy them and guarantee no new allocations will happen.
-
void rdma_copy_ah_attr(struct rdma_ah_attr *dest, const struct rdma_ah_attr *src)¶
Copy rdma ah attribute from source to destination.
Parameters
struct rdma_ah_attr *destPointer to destination ah_attr. Contents of the destination pointer is assumed to be invalid and attribute are overwritten.
const struct rdma_ah_attr *srcPointer to source ah_attr.
-
void rdma_replace_ah_attr(struct rdma_ah_attr *old, const struct rdma_ah_attr *new)¶
Replace valid ah_attr with new one.
Parameters
struct rdma_ah_attr *oldPointer to existing ah_attr which needs to be replaced. old is assumed to be valid or zero’d
const struct rdma_ah_attr *newPointer to the new ah_attr.
Description
rdma_replace_ah_attr() first releases any reference in the old ah_attr if
old the ah_attr is valid; after that it copies the new attribute and holds
the reference to the replaced ah_attr.
-
void rdma_move_ah_attr(struct rdma_ah_attr *dest, struct rdma_ah_attr *src)¶
Move ah_attr pointed by source to destination.
Parameters
struct rdma_ah_attr *destPointer to destination ah_attr to copy to. dest is assumed to be valid or zero’d
struct rdma_ah_attr *srcPointer to the new ah_attr.
Description
rdma_move_ah_attr() first releases any reference in the destination ah_attr
if it is valid. This also transfers ownership of internal references from
src to dest, making src invalid in the process. No new reference of the src
ah_attr is taken.
-
struct ib_ah *rdma_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr, u32 flags)¶
Creates an address handle for the given address vector.
Parameters
struct ib_pd *pdThe protection domain associated with the address handle.
struct rdma_ah_attr *ah_attrThe attributes of the address vector.
u32 flagsCreate address handle flags (see enum rdma_create_ah_flags).
Description
It returns 0 on success and returns appropriate error code on error. The address handle is used to reference a local or global destination in all UD QP post sends.
-
struct ib_ah *rdma_create_user_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr, struct ib_udata *udata)¶
Creates an address handle for the given address vector. It resolves destination mac address for ah attribute of RoCE type.
Parameters
struct ib_pd *pdThe protection domain associated with the address handle.
struct rdma_ah_attr *ah_attrThe attributes of the address vector.
struct ib_udata *udatapointer to user’s input output buffer information need by provider driver.
Description
It returns 0 on success and returns appropriate error code on error. The address handle is used to reference a local or global destination in all UD QP post sends.
-
void rdma_move_grh_sgid_attr(struct rdma_ah_attr *attr, union ib_gid *dgid, u32 flow_label, u8 hop_limit, u8 traffic_class, const struct ib_gid_attr *sgid_attr)¶
Sets the sgid attribute of GRH, taking ownership of the reference
Parameters
struct rdma_ah_attr *attrPointer to AH attribute structure
union ib_gid *dgidDestination GID
u32 flow_labelFlow label
u8 hop_limitHop limit
u8 traffic_classtraffic class
const struct ib_gid_attr *sgid_attrPointer to SGID attribute
Description
This takes ownership of the sgid_attr reference. The caller must ensure
rdma_destroy_ah_attr() is called before destroying the rdma_ah_attr after
calling this function.
-
void rdma_destroy_ah_attr(struct rdma_ah_attr *ah_attr)¶
Release reference to SGID attribute of ah attribute.
Parameters
struct rdma_ah_attr *ah_attrPointer to ah attribute
Description
Release reference to the SGID attribute of the ah attribute if it is non NULL. It is safe to call this multiple times, and safe to call it on a zero initialized ah_attr.
-
struct ib_srq *ib_create_srq_user(struct ib_pd *pd, struct ib_srq_init_attr *srq_init_attr, struct ib_usrq_object *uobject, struct ib_udata *udata)¶
Creates a SRQ associated with the specified protection domain.
Parameters
struct ib_pd *pdThe protection domain associated with the SRQ.
struct ib_srq_init_attr *srq_init_attrA list of initial attributes required to create the SRQ. If SRQ creation succeeds, then the attributes are updated to the actual capabilities of the created SRQ.
struct ib_usrq_object *uobjectuobject pointer if this is not a kernel SRQ
struct ib_udata *udataudata pointer if this is not a kernel SRQ
Description
srq_attr->max_wr and srq_attr->max_sge are read the determine the requested size of the SRQ, and set to the actual values allocated on return. If ib_create_srq() succeeds, then max_wr and max_sge will always be at least as large as the requested values.
-
struct ib_qp *ib_create_qp_user(struct ib_device *dev, struct ib_pd *pd, struct ib_qp_init_attr *attr, struct ib_udata *udata, struct ib_uqp_object *uobj, const char *caller)¶
Creates a QP associated with the specified protection domain.
Parameters
struct ib_device *devIB device
struct ib_pd *pdThe protection domain associated with the QP.
struct ib_qp_init_attr *attrA list of initial attributes required to create the QP. If QP creation succeeds, then the attributes are updated to the actual capabilities of the created QP.
struct ib_udata *udataUser data
struct ib_uqp_object *uobjuverbs obect
const char *callercaller’s build-time module name
-
int ib_modify_qp_with_udata(struct ib_qp *ib_qp, struct ib_qp_attr *attr, int attr_mask, struct ib_udata *udata)¶
Modifies the attributes for the specified QP.
Parameters
struct ib_qp *ib_qpThe QP to modify.
struct ib_qp_attr *attrOn input, specifies the QP attributes to modify. On output, the current values of selected QP attributes are returned.
int attr_maskA bit-mask used to specify which attributes of the QP are being modified.
struct ib_udata *udatapointer to user’s input output buffer information are being modified. It returns 0 on success and returns appropriate error code on error.
-
struct ib_mr *ib_alloc_mr(struct ib_pd *pd, enum ib_mr_type mr_type, u32 max_num_sg)¶
Allocates a memory region
Parameters
struct ib_pd *pdprotection domain associated with the region
enum ib_mr_type mr_typememory region type
u32 max_num_sgmaximum sg entries available for registration.
Notes
Memory registeration page/sg lists must not exceed max_num_sg. For mr_type IB_MR_TYPE_MEM_REG, the total length cannot exceed max_num_sg * used_page_size.
-
struct ib_mr *ib_alloc_mr_integrity(struct ib_pd *pd, u32 max_num_data_sg, u32 max_num_meta_sg)¶
Allocates an integrity memory region
Parameters
struct ib_pd *pdprotection domain associated with the region
u32 max_num_data_sgmaximum data sg entries available for registration
u32 max_num_meta_sgmaximum metadata sg entries available for registration
Notes
Memory registration page/sg lists must not exceed max_num_sg, also the integrity page/sg lists must not exceed max_num_meta_sg.
-
struct ib_xrcd *ib_alloc_xrcd_user(struct ib_device *device, struct inode *inode, struct ib_udata *udata)¶
Allocates an XRC domain.
Parameters
struct ib_device *deviceThe device on which to allocate the XRC domain.
struct inode *inodeinode to connect XRCD
struct ib_udata *udataValid user data or NULL for kernel object
-
int ib_dealloc_xrcd_user(struct ib_xrcd *xrcd, struct ib_udata *udata)¶
Deallocates an XRC domain.
Parameters
struct ib_xrcd *xrcdThe XRC domain to deallocate.
struct ib_udata *udataValid user data or NULL for kernel object
-
struct ib_wq *ib_create_wq(struct ib_pd *pd, struct ib_wq_init_attr *wq_attr)¶
Creates a WQ associated with the specified protection domain.
Parameters
struct ib_pd *pdThe protection domain associated with the WQ.
struct ib_wq_init_attr *wq_attrA list of initial attributes required to create the WQ. If WQ creation succeeds, then the attributes are updated to the actual capabilities of the created WQ.
Description
wq_attr->max_wr and wq_attr->max_sge determine
the requested size of the WQ, and set to the actual values allocated
on return.
If ib_create_wq() succeeds, then max_wr and max_sge will always be
at least as large as the requested values.
-
int ib_destroy_wq_user(struct ib_wq *wq, struct ib_udata *udata)¶
Destroys the specified user WQ.
Parameters
struct ib_wq *wqThe WQ to destroy.
struct ib_udata *udataValid user data
-
int ib_map_mr_sg_pi(struct ib_mr *mr, struct scatterlist *data_sg, int data_sg_nents, unsigned int *data_sg_offset, struct scatterlist *meta_sg, int meta_sg_nents, unsigned int *meta_sg_offset, unsigned int page_size)¶
Map the dma mapped SG lists for PI (protection information) and set an appropriate memory region for registration.
Parameters
struct ib_mr *mrmemory region
struct scatterlist *data_sgdma mapped scatterlist for data
int data_sg_nentsnumber of entries in data_sg
unsigned int *data_sg_offsetoffset in bytes into data_sg
struct scatterlist *meta_sgdma mapped scatterlist for metadata
int meta_sg_nentsnumber of entries in meta_sg
unsigned int *meta_sg_offsetoffset in bytes into meta_sg
unsigned int page_sizepage vector desired page size
Description
Constraints: - The MR must be allocated with type IB_MR_TYPE_INTEGRITY.
After this completes successfully, the memory region is ready for registration.
Return
0 on success.
-
int ib_map_mr_sg(struct ib_mr *mr, struct scatterlist *sg, int sg_nents, unsigned int *sg_offset, unsigned int page_size)¶
Map the largest prefix of a dma mapped SG list and set it the memory region.
Parameters
struct ib_mr *mrmemory region
struct scatterlist *sgdma mapped scatterlist
int sg_nentsnumber of entries in sg
unsigned int *sg_offsetoffset in bytes into sg
unsigned int page_sizepage vector desired page size
Description
Constraints:
The first sg element is allowed to have an offset.
Each sg element must either be aligned to page_size or virtually contiguous to the previous element. In case an sg element has a non-contiguous offset, the mapping prefix will not include it.
The last sg element is allowed to have length less than page_size.
If sg_nents total byte length exceeds the mr max_num_sge * page_size then only max_num_sg entries will be mapped.
If the MR was allocated with type IB_MR_TYPE_SG_GAPS, none of these constraints holds and the page_size argument is ignored.
Returns the number of sg elements that were mapped to the memory region.
After this completes successfully, the memory region is ready for registration.
-
int ib_sg_to_pages(struct ib_mr *mr, struct scatterlist *sgl, int sg_nents, unsigned int *sg_offset_p, int (*set_page)(struct ib_mr*, u64))¶
Convert the largest prefix of a sg list to a page vector
Parameters
struct ib_mr *mrmemory region
struct scatterlist *sgldma mapped scatterlist
int sg_nentsnumber of entries in sg
unsigned int *sg_offset_pIN
start offset in bytes into sg
OUT
offset in bytes for element n of the sg of the first byte that has not been processed where n is the return value of this function.
int (*set_page)(struct ib_mr *, u64)driver page assignment function pointer
Description
Core service helper for drivers to convert the largest prefix of given sg list to a page vector. The sg list prefix converted is the prefix that meet the requirements of ib_map_mr_sg.
Returns the number of sg elements that were assigned to a page vector.
-
void ib_drain_sq(struct ib_qp *qp)¶
Block until all SQ CQEs have been consumed by the application.
Parameters
struct ib_qp *qpqueue pair to drain
Description
If the device has a provider-specific drain function, then call that. Otherwise call the generic drain function __ib_drain_sq().
The caller must:
ensure there is room in the CQ and SQ for the drain work request and completion.
allocate the CQ using ib_alloc_cq().
ensure that there are no other contexts that are posting WRs concurrently. Otherwise the drain is not guaranteed.
-
void ib_drain_rq(struct ib_qp *qp)¶
Block until all RQ CQEs have been consumed by the application.
Parameters
struct ib_qp *qpqueue pair to drain
Description
If the device has a provider-specific drain function, then call that. Otherwise call the generic drain function __ib_drain_rq().
The caller must:
ensure there is room in the CQ and RQ for the drain work request and completion.
allocate the CQ using ib_alloc_cq().
ensure that there are no other contexts that are posting WRs concurrently. Otherwise the drain is not guaranteed.
-
void ib_drain_qp(struct ib_qp *qp)¶
Block until all CQEs have been consumed by the application on both the RQ and SQ.
Parameters
struct ib_qp *qpqueue pair to drain
Description
The caller must:
ensure there is room in the CQ(s), SQ, and RQ for drain work requests and completions.
allocate the CQs using ib_alloc_cq().
ensure that there are no other contexts that are posting WRs concurrently. Otherwise the drain is not guaranteed.
-
struct rdma_hw_stats *rdma_alloc_hw_stats_struct(const struct rdma_stat_desc *descs, int num_counters, unsigned long lifespan)¶
Helper function to allocate dynamic struct for the drivers.
Parameters
const struct rdma_stat_desc *descsarray of static descriptors
int num_countersnumber of elements in array
unsigned long lifespanmilliseconds between updates
-
void rdma_free_hw_stats_struct(struct rdma_hw_stats *stats)¶
Helper function to release rdma_hw_stats
Parameters
struct rdma_hw_stats *statsstatistics to release
-
void ib_pack(const struct ib_field *desc, int desc_len, void *structure, void *buf)¶
Pack a structure into a buffer
Parameters
const struct ib_field *descArray of structure field descriptions
int desc_lenNumber of entries in desc
void *structureStructure to pack from
void *bufBuffer to pack into
Description
ib_pack() packs a list of structure fields into a buffer,
controlled by the array of fields in desc.
-
void ib_unpack(const struct ib_field *desc, int desc_len, void *buf, void *structure)¶
Unpack a buffer into a structure
Parameters
const struct ib_field *descArray of structure field descriptions
int desc_lenNumber of entries in desc
void *bufBuffer to unpack from
void *structureStructure to unpack into
Description
ib_pack() unpacks a list of structure fields from a buffer,
controlled by the array of fields in desc.
-
void ib_sa_cancel_query(int id, struct ib_sa_query *query)¶
try to cancel an SA query
Parameters
int idID of query to cancel
struct ib_sa_query *queryquery pointer to cancel
Description
Try to cancel an SA query. If the id and query don’t match up or the query has already completed, nothing is done. Otherwise the query is canceled and will complete with a status of -EINTR.
-
int ib_init_ah_attr_from_path(struct ib_device *device, u32 port_num, struct sa_path_rec *rec, struct rdma_ah_attr *ah_attr, const struct ib_gid_attr *gid_attr)¶
Initialize address handle attributes based on an SA path record.
Parameters
struct ib_device *deviceDevice associated ah attributes initialization.
u32 port_numPort on the specified device.
struct sa_path_rec *recpath record entry to use for ah attributes initialization.
struct rdma_ah_attr *ah_attraddress handle attributes to initialization from path record.
const struct ib_gid_attr *gid_attrSGID attribute to consider during initialization.
Description
When ib_init_ah_attr_from_path() returns success,
(a) for IB link layer it optionally contains a reference to SGID attribute
when GRH is present for IB link layer.
(b) for RoCE link layer it contains a reference to SGID attribute.
User must invoke rdma_destroy_ah_attr() to release reference to SGID
attributes which are initialized using ib_init_ah_attr_from_path().
-
int ib_sa_path_rec_get(struct ib_sa_client *client, struct ib_device *device, u32 port_num, struct sa_path_rec *rec, ib_sa_comp_mask comp_mask, unsigned long timeout_ms, gfp_t gfp_mask, void (*callback)(int status, struct sa_path_rec *resp, unsigned int num_paths, void *context), void *context, struct ib_sa_query **sa_query)¶
Start a Path get query
Parameters
struct ib_sa_client *clientSA client
struct ib_device *devicedevice to send query on
u32 port_numport number to send query on
struct sa_path_rec *recPath Record to send in query
ib_sa_comp_mask comp_maskcomponent mask to send in query
unsigned long timeout_mstime to wait for response
gfp_t gfp_maskGFP mask to use for internal allocations
void (*callback)(int status, struct sa_path_rec *resp, unsigned int num_paths, void *context)function called when query completes, times out or is canceled
void *contextopaque user context passed to callback
struct ib_sa_query **sa_queryquery context, used to cancel query
Description
Send a Path Record Get query to the SA to look up a path. The callback function will be called when the query completes (or fails); status is 0 for a successful response, -EINTR if the query is canceled, -ETIMEDOUT is the query timed out, or -EIO if an error occurred sending the query. The resp parameter of the callback is only valid if status is 0.
If the return value of ib_sa_path_rec_get() is negative, it is an
error code. Otherwise it is a query ID that can be used to cancel
the query.
-
int ib_ud_header_init(int payload_bytes, int lrh_present, int eth_present, int vlan_present, int grh_present, int ip_version, int udp_present, int immediate_present, struct ib_ud_header *header)¶
Initialize UD header structure
Parameters
int payload_bytesLength of packet payload
int lrh_presentspecify if LRH is present
int eth_presentspecify if Eth header is present
int vlan_presentpacket is tagged vlan
int grh_presentGRH flag (if non-zero, GRH will be included)
int ip_versionif non-zero, IP header, V4 or V6, will be included
int udp_presentif non-zero, UDP header will be included
int immediate_presentspecify if immediate data is present
struct ib_ud_header *headerStructure to initialize
-
int ib_ud_header_pack(struct ib_ud_header *header, void *buf)¶
Pack UD header struct into wire format
Parameters
struct ib_ud_header *headerUD header struct
void *bufBuffer to pack into
Description
ib_ud_header_pack() packs the UD header structure header into wire
format in the buffer buf.
-
unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem, unsigned long pgsz_bitmap, unsigned long virt)¶
Find best HW page size to use for this MR
Parameters
struct ib_umem *umemumem struct
unsigned long pgsz_bitmapbitmap of HW supported page sizes
unsigned long virtIOVA
Description
This helper is intended for HW that support multiple page sizes but can do only a single page size in an MR.
Returns 0 if the umem requires page sizes not supported by the driver to be mapped. Drivers always supporting PAGE_SIZE or smaller will never see a 0 result.
-
struct ib_umem *ib_umem_get(struct ib_device *device, unsigned long addr, size_t size, int access)¶
Pin and DMA map userspace memory.
Parameters
struct ib_device *deviceIB device to connect UMEM
unsigned long addruserspace virtual address to start at
size_t sizelength of region to pin
int accessIB_ACCESS_xxx flags for memory being pinned
-
void ib_umem_release(struct ib_umem *umem)¶
release memory pinned with ib_umem_get
Parameters
struct ib_umem *umemumem struct to release
-
struct ib_umem_odp *ib_umem_odp_alloc_implicit(struct ib_device *device, int access)¶
Allocate a parent implicit ODP umem
Parameters
struct ib_device *deviceIB device to create UMEM
int accessib_reg_mr access flags
Description
Implicit ODP umems do not have a VA range and do not have any page lists. They exist only to hold the per_mm reference to help the driver create children umems.
-
struct ib_umem_odp *ib_umem_odp_alloc_child(struct ib_umem_odp *root, unsigned long addr, size_t size, const struct mmu_interval_notifier_ops *ops)¶
Allocate a child ODP umem under an implicit parent ODP umem
Parameters
struct ib_umem_odp *rootThe parent umem enclosing the child. This must be allocated using ib_alloc_implicit_odp_umem()
unsigned long addrThe starting userspace VA
size_t sizeThe length of the userspace VA
const struct mmu_interval_notifier_ops *opsMMU interval ops, currently only invalidate
-
struct ib_umem_odp *ib_umem_odp_get(struct ib_device *device, unsigned long addr, size_t size, int access, const struct mmu_interval_notifier_ops *ops)¶
Create a umem_odp for a userspace va
Parameters
struct ib_device *deviceIB device struct to get UMEM
unsigned long addruserspace virtual address to start at
size_t sizelength of region to pin
int accessIB_ACCESS_xxx flags for memory being pinned
const struct mmu_interval_notifier_ops *opsMMU interval ops, currently only invalidate
Description
The driver should use when the access flags indicate ODP memory. It avoids pinning, instead, stores the mm for future page fault handling in conjunction with MMU notifiers.
-
int ib_umem_odp_map_dma_and_lock(struct ib_umem_odp *umem_odp, u64 user_virt, u64 bcnt, u64 access_mask, bool fault)¶
DMA map userspace memory in an ODP MR and lock it.
Parameters
struct ib_umem_odp *umem_odpthe umem to map and pin
u64 user_virtthe address from which we need to map.
u64 bcntthe minimal number of bytes to pin and map. The mapping might be bigger due to alignment, and may also be smaller in case of an error pinning or mapping a page. The actual pages mapped is returned in the return value.
u64 access_maskbit mask of the requested access permissions for the given range.
bool faultis faulting required for the given range
Description
Maps the range passed in the argument to DMA addresses. The DMA addresses of the mapped pages is updated in umem_odp->dma_list. Upon success the ODP MR will be locked to let caller complete its device page table update.
Returns the number of pages mapped in success, negative error code for failure.
RDMA Verbs transport library¶
-
int rvt_fast_reg_mr(struct rvt_qp *qp, struct ib_mr *ibmr, u32 key, int access)¶
fast register physical MR
Parameters
struct rvt_qp *qpthe queue pair where the work request comes from
struct ib_mr *ibmrthe memory region to be registered
u32 keyupdated key for this memory region
int accessaccess flags for this memory region
Description
Returns 0 on success.
-
int rvt_invalidate_rkey(struct rvt_qp *qp, u32 rkey)¶
invalidate an MR rkey
Parameters
struct rvt_qp *qpqueue pair associated with the invalidate op
u32 rkeyrkey to invalidate
Description
Returns 0 on success.
-
int rvt_lkey_ok(struct rvt_lkey_table *rkt, struct rvt_pd *pd, struct rvt_sge *isge, struct rvt_sge *last_sge, struct ib_sge *sge, int acc)¶
check IB SGE for validity and initialize
Parameters
struct rvt_lkey_table *rkttable containing lkey to check SGE against
struct rvt_pd *pdprotection domain
struct rvt_sge *isgeoutgoing internal SGE
struct rvt_sge *last_sgelast outgoing SGE written
struct ib_sge *sgeSGE to check
int accaccess flags
Description
Check the IB SGE for validity and initialize our internal version of it.
Increments the reference count when a new sge is stored.
Return
0 if compressed, 1 if added , otherwise returns -errno.
-
int rvt_rkey_ok(struct rvt_qp *qp, struct rvt_sge *sge, u32 len, u64 vaddr, u32 rkey, int acc)¶
check the IB virtual address, length, and RKEY
Parameters
struct rvt_qp *qpqp for validation
struct rvt_sge *sgeSGE state
u32 lenlength of data
u64 vaddrvirtual address to place data
u32 rkeyrkey to check
int accaccess flags
Return
1 if successful, otherwise 0.
Description
increments the reference count upon success
-
__be32 rvt_compute_aeth(struct rvt_qp *qp)¶
compute the AETH (syndrome + MSN)
Parameters
struct rvt_qp *qpthe queue pair to compute the AETH for
Description
Returns the AETH.
-
void rvt_get_credit(struct rvt_qp *qp, u32 aeth)¶
flush the send work queue of a QP
Parameters
struct rvt_qp *qpthe qp who’s send work queue to flush
u32 aeththe Acknowledge Extended Transport Header
Description
The QP s_lock should be held.
-
u32 rvt_restart_sge(struct rvt_sge_state *ss, struct rvt_swqe *wqe, u32 len)¶
rewind the sge state for a wqe
Parameters
struct rvt_sge_state *ssthe sge state pointer
struct rvt_swqe *wqethe wqe to rewind
u32 lenthe data length from the start of the wqe in bytes
Description
Returns the remaining data length.
-
int rvt_check_ah(struct ib_device *ibdev, struct rdma_ah_attr *ah_attr)¶
validate the attributes of AH
Parameters
struct ib_device *ibdevthe ib device
struct rdma_ah_attr *ah_attrthe attributes of the AH
Description
If driver supports a more detailed check_ah function call back to it otherwise just check the basics.
Return
0 on success
-
struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)¶
allocate rdi
Parameters
size_t sizehow big of a structure to allocate
int nportsnumber of ports to allocate array slots for
Description
Use IB core device alloc to allocate space for the rdi which is assumed to be inside of the ib_device. Any extra space that drivers require should be included in size.
We also allocate a port array based on the number of ports.
Return
pointer to allocated rdi
-
void rvt_dealloc_device(struct rvt_dev_info *rdi)¶
deallocate rdi
Parameters
struct rvt_dev_info *rdistructure to free
Description
Free a structure allocated with rvt_alloc_device()
-
int rvt_register_device(struct rvt_dev_info *rdi)¶
register a driver
Parameters
struct rvt_dev_info *rdimain dev structure for all of rdmavt operations
Description
It is up to drivers to allocate the rdi and fill in the appropriate information.
Return
0 on success otherwise an errno.
-
void rvt_unregister_device(struct rvt_dev_info *rdi)¶
remove a driver
Parameters
struct rvt_dev_info *rdirvt dev struct
-
int rvt_init_port(struct rvt_dev_info *rdi, struct rvt_ibport *port, int port_index, u16 *pkey_table)¶
init internal data for driver port
Parameters
struct rvt_dev_info *rdirvt_dev_info struct
struct rvt_ibport *portrvt port
int port_index0 based index of ports, different from IB core port num
u16 *pkey_tablepkey_table for port
Description
Keep track of a list of ports. No need to have a detach port. They persist until the driver goes away.
Return
always 0
-
bool rvt_cq_enter(struct rvt_cq *cq, struct ib_wc *entry, bool solicited)¶
add a new entry to the completion queue
Parameters
struct rvt_cq *cqcompletion queue
struct ib_wc *entrywork completion entry to add
bool solicitedtrue if entry is solicited
Description
This may be called with qp->s_lock held.
Return
return true on success, else return false if cq is full.
-
int rvt_error_qp(struct rvt_qp *qp, enum ib_wc_status err)¶
put a QP into the error state
Parameters
struct rvt_qp *qpthe QP to put into the error state
enum ib_wc_status errthe receive completion error to signal if a RWQE is active
Description
Flushes both send and receive work queues.
Return
true if last WQE event should be generated. The QP r_lock and s_lock should be held and interrupts disabled. If we are already in error state, just return.
-
int rvt_get_rwqe(struct rvt_qp *qp, bool wr_id_only)¶
copy the next RWQE into the QP’s RWQE
Parameters
struct rvt_qp *qpthe QP
bool wr_id_onlyupdate qp->r_wr_id only, not qp->r_sge
Description
Return -1 if there is a local error, 0 if no RWQE is available, otherwise return 1.
Can be called from interrupt level.
-
void rvt_comm_est(struct rvt_qp *qp)¶
handle trap with QP established
Parameters
struct rvt_qp *qpthe QP
-
void rvt_add_rnr_timer(struct rvt_qp *qp, u32 aeth)¶
add/start an rnr timer on the QP
Parameters
struct rvt_qp *qpthe QP
u32 aethaeth of RNR timeout, simulated aeth for loopback
-
void rvt_stop_rc_timers(struct rvt_qp *qp)¶
stop all timers
Parameters
struct rvt_qp *qpthe QP stop any pending timers
-
void rvt_del_timers_sync(struct rvt_qp *qp)¶
wait for any timeout routines to exit
Parameters
struct rvt_qp *qpthe QP
-
struct rvt_qp_iter *rvt_qp_iter_init(struct rvt_dev_info *rdi, u64 v, void (*cb)(struct rvt_qp *qp, u64 v))¶
initial for QP iteration
Parameters
struct rvt_dev_info *rdirvt devinfo
u64 vu64 value
void (*cb)(struct rvt_qp *qp, u64 v)user-defined callback
Description
This returns an iterator suitable for iterating QPs in the system.
The cb is a user-defined callback and v is a 64-bit value passed to and relevant for processing in the cb. An example use case would be to alter QP processing based on criteria not part of the rvt_qp.
Use cases that require memory allocation to succeed must preallocate appropriately.
Return
a pointer to an rvt_qp_iter or NULL
-
int rvt_qp_iter_next(struct rvt_qp_iter *iter)¶
return the next QP in iter
Parameters
struct rvt_qp_iter *iterthe iterator
Description
Fine grained QP iterator suitable for use with debugfs seq_file mechanisms.
Updates iter->qp with the current QP when the return value is 0.
Return
0 - iter->qp is valid 1 - no more QPs
-
void rvt_qp_iter(struct rvt_dev_info *rdi, u64 v, void (*cb)(struct rvt_qp *qp, u64 v))¶
iterate all QPs
Parameters
struct rvt_dev_info *rdirvt devinfo
u64 va 64-bit value
void (*cb)(struct rvt_qp *qp, u64 v)a callback
Description
This provides a way for iterating all QPs.
The cb is a user-defined callback and v is a 64-bit value passed to and relevant for processing in the cb. An example use case would be to alter QP processing based on criteria not part of the rvt_qp.
The code has an internal iterator to simplify non seq_file use cases.
-
void rvt_copy_sge(struct rvt_qp *qp, struct rvt_sge_state *ss, void *data, u32 length, bool release, bool copy_last)¶
copy data to SGE memory
Parameters
struct rvt_qp *qpassociated QP
struct rvt_sge_state *ssthe SGE state
void *datathe data to copy
u32 lengththe length of the data
bool releaseboolean to release MR
bool copy_lastdo a separate copy of the last 8 bytes
-
void rvt_ruc_loopback(struct rvt_qp *sqp)¶
handle UC and RC loopback requests
Parameters
struct rvt_qp *sqpthe sending QP
Description
This is called from rvt_do_send() to forward a WQE addressed to the same HFI Note that although we are single threaded due to the send engine, we still have to protect against post_send(). We don’t have to worry about receive interrupts since this is a connected protocol and all packets will pass through here.
-
struct rvt_mcast *rvt_mcast_find(struct rvt_ibport *ibp, union ib_gid *mgid, u16 lid)¶
search the global table for the given multicast GID/LID
Parameters
struct rvt_ibport *ibpthe IB port structure
union ib_gid *mgidthe multicast GID to search for
u16 lidthe multicast LID portion of the multicast address (host order)
NOTE
It is valid to have 1 MLID with multiple MGIDs. It is not valid to have 1 MGID with multiple MLIDs.
Description
The caller is responsible for decrementing the reference count if found.
Return
NULL if not found.
Upper Layer Protocols¶
iSCSI Extensions for RDMA (iSER)¶
-
struct iser_data_buf¶
iSER data buffer
Definition:
struct iser_data_buf {
struct scatterlist *sg;
int size;
unsigned long data_len;
int dma_nents;
};
Members
sgpointer to the sg list
sizenum entries of this sg
data_lentotal buffer byte len
dma_nentsreturned by dma_map_sg
-
struct iser_mem_reg¶
iSER memory registration info
Definition:
struct iser_mem_reg {
struct ib_sge sge;
u32 rkey;
struct iser_fr_desc *desc;
};
Members
sgememory region sg element
rkeymemory region remote key
descpointer to fast registration context
-
struct iser_tx_desc¶
iSER TX descriptor
Definition:
struct iser_tx_desc {
struct iser_ctrl iser_header;
struct iscsi_hdr iscsi_header;
enum iser_desc_type type;
u64 dma_addr;
struct ib_sge tx_sg[2];
int num_sge;
struct ib_cqe cqe;
bool mapped;
struct ib_reg_wr reg_wr;
struct ib_send_wr send_wr;
struct ib_send_wr inv_wr;
};
Members
iser_headeriser header
iscsi_headeriscsi header
typecommand/control/dataout
dma_addrheader buffer dma_address
tx_sgsg[0] points to iser/iscsi headers sg[1] optionally points to either of immediate data unsolicited data-out or control
num_sgenumber sges used on this TX task
cqecompletion handler
mappedIs the task header mapped
reg_wrregistration WR
send_wrsend WR
inv_wrinvalidate WR
-
struct iser_rx_desc¶
iSER RX descriptor
Definition:
struct iser_rx_desc {
struct iser_ctrl iser_header;
struct iscsi_hdr iscsi_header;
char data[ISER_RECV_DATA_SEG_LEN];
u64 dma_addr;
struct ib_sge rx_sg;
struct ib_cqe cqe;
char pad[ISER_RX_PAD_SIZE];
};
Members
iser_headeriser header
iscsi_headeriscsi header
datareceived data segment
dma_addrreceive buffer dma address
rx_sgib_sge of receive buffer
cqecompletion handler
padfor sense data TODO: Modify to maximum sense length supported
-
struct iser_login_desc¶
iSER login descriptor
Definition:
struct iser_login_desc {
void *req;
void *rsp;
u64 req_dma;
u64 rsp_dma;
struct ib_sge sge;
struct ib_cqe cqe;
};
Members
reqpointer to login request buffer
rsppointer to login response buffer
req_dmaDMA address of login request buffer
rsp_dmaDMA address of login response buffer
sgeIB sge for login post recv
cqecompletion handler
-
struct iser_device¶
iSER device handle
Definition:
struct iser_device {
struct ib_device *ib_device;
struct ib_pd *pd;
struct ib_event_handler event_handler;
struct list_head ig_list;
int refcount;
};
Members
ib_deviceRDMA device
pdProtection Domain for this device
event_handlerIB events handle routine
ig_listentry in devices list
refcountReference counter, dominated by open iser connections
-
struct iser_reg_resources¶
Fast registration resources
Definition:
struct iser_reg_resources {
struct ib_mr *mr;
struct ib_mr *sig_mr;
};
Members
mrmemory region
sig_mrsignature memory region
-
struct iser_fr_desc¶
Fast registration descriptor
Definition:
struct iser_fr_desc {
struct list_head list;
struct iser_reg_resources rsc;
bool sig_protected;
struct list_head all_list;
};
Members
listentry in connection fastreg pool
rscdata buffer registration resources
sig_protectedis region protected indicator
all_listfirst and last list members
-
struct iser_fr_pool¶
connection fast registration pool
Definition:
struct iser_fr_pool {
struct list_head list;
spinlock_t lock;
int size;
struct list_head all_list;
};
Members
listlist of fastreg descriptors
lockprotects fastreg pool
sizesize of the pool
all_listfirst and last list members
-
struct ib_conn¶
Infiniband related objects
Definition:
struct ib_conn {
struct rdma_cm_id *cma_id;
struct ib_qp *qp;
struct ib_cq *cq;
u32 cq_size;
struct iser_device *device;
struct iser_fr_pool fr_pool;
bool pi_support;
struct ib_cqe reg_cqe;
};
Members
cma_idrdma_cm connection maneger handle
qpConnection Queue-pair
cqConnection completion queue
cq_sizeThe number of max outstanding completions
devicereference to iser device
fr_poolconnection fast registration pool
pi_supportIndicate device T10-PI support
reg_cqecompletion handler
-
struct iser_conn¶
iSER connection context
Definition:
struct iser_conn {
struct ib_conn ib_conn;
struct iscsi_conn *iscsi_conn;
struct iscsi_endpoint *ep;
enum iser_conn_state state;
unsigned qp_max_recv_dtos;
u16 max_cmds;
char name[ISER_OBJECT_NAME_SIZE];
struct work_struct release_work;
struct mutex state_mutex;
struct completion stop_completion;
struct completion ib_completion;
struct completion up_completion;
struct list_head conn_list;
struct iser_login_desc login_desc;
struct iser_rx_desc *rx_descs;
u32 num_rx_descs;
unsigned short scsi_sg_tablesize;
unsigned short pages_per_mr;
bool snd_w_inv;
};
Members
ib_connconnection RDMA resources
iscsi_connlink to matching iscsi connection
eptransport handle
stateconnection logical state
qp_max_recv_dtosmaximum number of data outs, corresponds to max number of post recvs
max_cmdsmaximum cmds allowed for this connection
nameconnection peer portal
release_workdeferred work for release job
state_mutexprotects iser onnection state
stop_completionconn_stop completion
ib_completionRDMA cleanup completion
up_completionconnection establishment completed (state is ISER_CONN_UP)
conn_listentry in ig conn list
login_desclogin descriptor
rx_descsrx buffers array (cyclic buffer)
num_rx_descsnumber of rx descriptors
scsi_sg_tablesizescsi host sg_tablesize
pages_per_mrmaximum pages available for registration
snd_w_invconnection uses remote invalidation
-
struct iscsi_iser_task¶
iser task context
Definition:
struct iscsi_iser_task {
struct iser_tx_desc desc;
struct iser_conn *iser_conn;
enum iser_task_status status;
struct scsi_cmnd *sc;
int command_sent;
int dir[ISER_DIRS_NUM];
struct iser_mem_reg rdma_reg[ISER_DIRS_NUM];
struct iser_data_buf data[ISER_DIRS_NUM];
struct iser_data_buf prot[ISER_DIRS_NUM];
};
Members
descTX descriptor
iser_connlink to iser connection
statuscurrent task status
sclink to scsi command
command_sentindicate if command was sent
diriser data direction
rdma_regtask rdma registration desc
dataiser data buffer desc
protiser protection buffer desc
-
struct iser_global¶
iSER global context
Definition:
struct iser_global {
struct mutex device_list_mutex;
struct list_head device_list;
struct mutex connlist_mutex;
struct list_head connlist;
struct kmem_cache *desc_cache;
};
Members
device_list_mutexprotects device_list
device_listiser devices global list
connlist_mutexprotects connlist
connlistiser connections global list
desc_cachekmem cache for tx dataout
-
int iscsi_iser_pdu_alloc(struct iscsi_task *task, uint8_t opcode)¶
allocate an iscsi-iser PDU
Parameters
struct iscsi_task *taskiscsi task
uint8_t opcodeiscsi command opcode
Description
- Netes: This routine can’t fail, just assign iscsi task
hdr and max hdr size.
-
int iser_initialize_task_headers(struct iscsi_task *task, struct iser_tx_desc *tx_desc)¶
Initialize task headers
Parameters
struct iscsi_task *taskiscsi task
struct iser_tx_desc *tx_desciser tx descriptor
Notes
This routine may race with iser teardown flow for scsi error handling TMFs. So for TMF we should acquire the state mutex to avoid dereferencing the IB device which may have already been terminated.
-
int iscsi_iser_task_init(struct iscsi_task *task)¶
Initialize iscsi-iser task
Parameters
struct iscsi_task *taskiscsi task
Description
Initialize the task for the scsi command or mgmt command.
Return
- Returns zero on success or -ENOMEM when failing
to init task headers (dma mapping error).
-
int iscsi_iser_mtask_xmit(struct iscsi_conn *conn, struct iscsi_task *task)¶
xmit management (immediate) task
Parameters
struct iscsi_conn *conniscsi connection
struct iscsi_task *tasktask management task
Notes
The function can return -EAGAIN in which case caller must call it again later, or recover. ‘0’ return code means successful xmit.
-
int iscsi_iser_task_xmit(struct iscsi_task *task)¶
xmit iscsi-iser task
Parameters
struct iscsi_task *taskiscsi task
Return
zero on success or escalates $error on failure.
-
void iscsi_iser_cleanup_task(struct iscsi_task *task)¶
cleanup an iscsi-iser task
Parameters
struct iscsi_task *taskiscsi task
Notes
- In case the RDMA device is already NULL (might have
been removed in DEVICE_REMOVAL CM event it will bail-out without doing dma unmapping.
-
u8 iscsi_iser_check_protection(struct iscsi_task *task, sector_t *sector)¶
check protection information status of task.
Parameters
struct iscsi_task *taskiscsi task
sector_t *sectorerror sector if exsists (output)
Return
- zero if no data-integrity errors have occurred
0x1: data-integrity error occurred in the guard-block 0x2: data-integrity error occurred in the reference tag 0x3: data-integrity error occurred in the application tag
In addition the error sector is marked.
-
struct iscsi_cls_conn *iscsi_iser_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)¶
create a new iscsi-iser connection
Parameters
struct iscsi_cls_session *cls_sessioniscsi class connection
uint32_t conn_idxconnection index within the session (for MCS)
Return
- iscsi_cls_conn when iscsi_conn_setup succeeds or NULL
otherwise.
-
int iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session, struct iscsi_cls_conn *cls_conn, uint64_t transport_eph, int is_leading)¶
bind iscsi and iser connection structures
Parameters
struct iscsi_cls_session *cls_sessioniscsi class session
struct iscsi_cls_conn *cls_conniscsi class connection
uint64_t transport_ephtransport end-point handle
int is_leadingindicate if this is the session leading connection (MCS)
Return
- zero on success, $error if iscsi_conn_bind fails and
-EINVAL in case end-point doesn’t exists anymore or iser connection state is not UP (teardown already started).
-
int iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)¶
start iscsi-iser connection
Parameters
struct iscsi_cls_conn *cls_conniscsi class connection
Notes
- Here iser intialize (or re-initialize) stop_completion as
from this point iscsi must call conn_stop in session/connection teardown so iser transport must wait for it.
-
void iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)¶
stop iscsi-iser connection
Parameters
struct iscsi_cls_conn *cls_conniscsi class connection
int flagindicate if recover or terminate (passed as is)
Notes
- Calling iscsi_conn_stop might theoretically race with
DEVICE_REMOVAL event and dereference a previously freed RDMA device handle, so we call it under iser the state lock to protect against this kind of race.
-
void iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session)¶
destroy iscsi-iser session
Parameters
struct iscsi_cls_session *cls_sessioniscsi class session
Description
Removes and free iscsi host.
-
struct iscsi_cls_session *iscsi_iser_session_create(struct iscsi_endpoint *ep, uint16_t cmds_max, uint16_t qdepth, uint32_t initial_cmdsn)¶
create an iscsi-iser session
Parameters
struct iscsi_endpoint *episcsi end-point handle
uint16_t cmds_maxmaximum commands in this session
uint16_t qdepthsession command queue depth
uint32_t initial_cmdsninitiator command sequnce number
Description
Allocates and adds a scsi host, expose DIF supprot if exists, and sets up an iscsi session.
-
struct iscsi_endpoint *iscsi_iser_ep_connect(struct Scsi_Host *shost, struct sockaddr *dst_addr, int non_blocking)¶
Initiate iSER connection establishment
Parameters
struct Scsi_Host *shostscsi_host
struct sockaddr *dst_addrdestination address
int non_blockingindicate if routine can block
Description
Allocate an iscsi endpoint, an iser_conn structure and bind them. After that start RDMA connection establishment via rdma_cm. We don’t allocate iser_conn embedded in iscsi_endpoint since in teardown the endpoint will be destroyed at ep_disconnect while iser_conn will cleanup its resources asynchronuously.
Return
- iscsi_endpoint created by iscsi layer or ERR_PTR(error)
if fails.
-
int iscsi_iser_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)¶
poll for iser connection establishment to complete
Parameters
struct iscsi_endpoint *episcsi endpoint (created at ep_connect)
int timeout_mspolling timeout allowed in ms.
Description
This routine boils down to waiting for up_completion signaling that cma_id got CONNECTED event.
Return
- 1 if succeeded in connection establishment, 0 if timeout expired
(libiscsi will retry will kick in) or -1 if interrupted by signal or more likely iser connection state transitioned to TEMINATING or DOWN during the wait period.
-
void iscsi_iser_ep_disconnect(struct iscsi_endpoint *ep)¶
Initiate connection teardown process
Parameters
struct iscsi_endpoint *episcsi endpoint handle
Description
This routine is not blocked by iser and RDMA termination process completion as we queue a deffered work for iser/RDMA destruction and cleanup or actually call it immediately in case we didn’t pass iscsi conn bind/start stage, thus it is safe.
-
int iser_send_command(struct iscsi_conn *conn, struct iscsi_task *task)¶
send command PDU
Parameters
struct iscsi_conn *connlink to matching iscsi connection
struct iscsi_task *taskSCSI command task
-
int iser_send_data_out(struct iscsi_conn *conn, struct iscsi_task *task, struct iscsi_data *hdr)¶
send data out PDU
Parameters
struct iscsi_conn *connlink to matching iscsi connection
struct iscsi_task *taskSCSI command task
struct iscsi_data *hdrpointer to the LLD’s iSCSI message header
-
int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max, unsigned int size)¶
Creates pool of fast_reg descriptors for fast registration work requests.
Parameters
struct ib_conn *ib_connconnection RDMA resources
unsigned cmds_maxmax number of SCSI commands for this connection
unsigned int sizemax number of pages per map request
Return
0 on success, or errno code on failure
Parameters
struct ib_conn *ib_connconnection RDMA resources
Parameters
struct iser_conn *iser_conniser connection struct
bool destroyindicator if we need to try to release the iser device and memory regoins pool (only iscsi shutdown and DEVICE_REMOVAL will use this).
Description
This routine is called with the iser state mutex held so the cm_id removal is out of here. It is Safe to be invoked multiple times.
-
void iser_conn_release(struct iser_conn *iser_conn)¶
Frees all conn objects and deallocs conn descriptor
Parameters
struct iser_conn *iser_conniSER connection context
-
int iser_conn_terminate(struct iser_conn *iser_conn)¶
triggers start of the disconnect procedures and waits for them to be done
Parameters
struct iser_conn *iser_conniSER connection context
Description
Called with state mutex held
-
int iser_post_send(struct ib_conn *ib_conn, struct iser_tx_desc *tx_desc)¶
Initiate a Send DTO operation
Parameters
struct ib_conn *ib_connconnection RDMA resources
struct iser_tx_desc *tx_desciSER TX descriptor
Return
0 on success, -1 on failure
Omni-Path (OPA) Virtual NIC support¶
-
struct opa_vnic_ctrl_port¶
OPA virtual NIC control port
Definition:
struct opa_vnic_ctrl_port {
struct ib_device *ibdev;
struct opa_vnic_ctrl_ops *ops;
u8 num_ports;
};
Members
ibdevpointer to ib device
opsopa vnic control operations
num_portsnumber of opa ports
-
struct opa_vnic_adapter¶
OPA VNIC netdev private data structure
Definition:
struct opa_vnic_adapter {
struct net_device *netdev;
struct ib_device *ibdev;
struct opa_vnic_ctrl_port *cport;
const struct net_device_ops *rn_ops;
u8 port_num;
u8 vport_num;
struct mutex lock;
struct __opa_veswport_info info;
u8 vema_mac_addr[ETH_ALEN];
u32 umac_hash;
u32 mmac_hash;
struct hlist_head __rcu *mactbl;
struct mutex mactbl_lock;
spinlock_t stats_lock;
u8 flow_tbl[OPA_VNIC_FLOW_TBL_SIZE];
unsigned long trap_timeout;
u8 trap_count;
};
Members
netdevpointer to associated netdev
ibdevib device
cportpointer to opa vnic control port
rn_opsrdma netdev’s net_device_ops
port_numOPA port number
vport_numvesw port number
lockadapter lock
infovirtual ethernet switch port information
vema_mac_addrmac address configured by vema
umac_hashunicast maclist hash
mmac_hashmulticast maclist hash
mactblhash table of MAC entries
mactbl_lockmac table lock
stats_lockstatistics lock
flow_tblflow to default port redirection table
trap_timeouttrap timeout
trap_countno. of traps allowed within timeout period
-
struct opa_vnic_mac_tbl_node¶
OPA VNIC mac table node
Definition:
struct opa_vnic_mac_tbl_node {
struct hlist_node hlist;
u16 index;
struct __opa_vnic_mactable_entry entry;
};
Members
hlisthash list handle
indexindex of entry in the mac table
entryentry in the table
-
struct opa_vesw_info¶
OPA vnic switch information
Definition:
struct opa_vesw_info {
__be16 fabric_id;
__be16 vesw_id;
u8 rsvd0[6];
__be16 def_port_mask;
u8 rsvd1[2];
__be16 pkey;
u8 rsvd2[4];
__be32 u_mcast_dlid;
__be32 u_ucast_dlid[OPA_VESW_MAX_NUM_DEF_PORT];
__be32 rc;
u8 rsvd3[56];
__be16 eth_mtu;
u8 rsvd4[2];
};
Members
fabric_id10-bit fabric id
vesw_id12-bit virtual ethernet switch id
rsvd0reserved bytes
def_port_maskbitmask of default ports
rsvd1reserved bytes
pkeypartition key
rsvd2reserved bytes
u_mcast_dlidunknown multicast dlid
u_ucast_dlidarray of unknown unicast dlids
rcrouting control
rsvd3reserved bytes
eth_mtuEthernet MTU
rsvd4reserved bytes
-
struct opa_per_veswport_info¶
OPA vnic per port information
Definition:
struct opa_per_veswport_info {
__be32 port_num;
u8 eth_link_status;
u8 rsvd0[3];
u8 base_mac_addr[ETH_ALEN];
u8 config_state;
u8 oper_state;
__be16 max_mac_tbl_ent;
__be16 max_smac_ent;
__be32 mac_tbl_digest;
u8 rsvd1[4];
__be32 encap_slid;
u8 pcp_to_sc_uc[OPA_VNIC_MAX_NUM_PCP];
u8 pcp_to_vl_uc[OPA_VNIC_MAX_NUM_PCP];
u8 pcp_to_sc_mc[OPA_VNIC_MAX_NUM_PCP];
u8 pcp_to_vl_mc[OPA_VNIC_MAX_NUM_PCP];
u8 non_vlan_sc_uc;
u8 non_vlan_vl_uc;
u8 non_vlan_sc_mc;
u8 non_vlan_vl_mc;
u8 rsvd2[48];
__be16 uc_macs_gen_count;
__be16 mc_macs_gen_count;
u8 rsvd3[8];
};
Members
port_numport number
eth_link_statuscurrent ethernet link state
rsvd0reserved bytes
base_mac_addrbase mac address
config_stateconfigured port state
oper_stateoperational port state
max_mac_tbl_entmax number of mac table entries
max_smac_entmax smac entries in mac table
mac_tbl_digestmac table digest
rsvd1reserved bytes
encap_slidbase slid for the port
pcp_to_sc_ucsc by pcp index for unicast ethernet packets
pcp_to_vl_ucvl by pcp index for unicast ethernet packets
pcp_to_sc_mcsc by pcp index for multicast ethernet packets
pcp_to_vl_mcvl by pcp index for multicast ethernet packets
non_vlan_sc_ucsc for non-vlan unicast ethernet packets
non_vlan_vl_ucvl for non-vlan unicast ethernet packets
non_vlan_sc_mcsc for non-vlan multicast ethernet packets
non_vlan_vl_mcvl for non-vlan multicast ethernet packets
rsvd2reserved bytes
uc_macs_gen_countgeneration count for unicast macs list
mc_macs_gen_countgeneration count for multicast macs list
rsvd3reserved bytes
-
struct opa_veswport_info¶
OPA vnic port information
Definition:
struct opa_veswport_info {
struct opa_vesw_info vesw;
struct opa_per_veswport_info vport;
};
Members
veswOPA vnic switch information
vportOPA vnic per port information
Description
On host, each of the virtual ethernet ports belongs to a different virtual ethernet switches.
-
struct opa_veswport_mactable_entry¶
single entry in the forwarding table
Definition:
struct opa_veswport_mactable_entry {
u8 mac_addr[ETH_ALEN];
u8 mac_addr_mask[ETH_ALEN];
__be32 dlid_sd;
};
Members
mac_addrMAC address
mac_addr_maskMAC address bit mask
dlid_sdMatching DLID and side data
Description
On the host each virtual ethernet port will have a forwarding table. These tables are used to map a MAC to a LID and other data. For more details see struct opa_veswport_mactable_entries. This is the structure of a single mactable entry
-
struct opa_veswport_mactable¶
Forwarding table array
Definition:
struct opa_veswport_mactable {
__be16 offset;
__be16 num_entries;
__be32 mac_tbl_digest;
struct opa_veswport_mactable_entry tbl_entries[];
};
Members
offsetmac table starting offset
num_entriesNumber of entries to get or set
mac_tbl_digestmac table digest
tbl_entriesArray of table entries
Description
The EM sends down this structure in a MAD indicating the starting offset in the forwarding table that this entry is to be loaded into and the number of entries that that this MAD instance contains The mac_tbl_digest has been added to this MAD structure. It will be set by the EM and it will be used by the EM to check if there are any discrepancies with this value and the value maintained by the EM in the case of VNIC port being deleted or unloaded A new instantiation of a VNIC will always have a value of zero. This value is stored as part of the vnic adapter structure and will be accessed by the GET and SET routines for both the mactable entries and the veswport info.
-
struct opa_veswport_summary_counters¶
summary counters
Definition:
struct opa_veswport_summary_counters {
__be16 vp_instance;
__be16 vesw_id;
__be32 veswport_num;
__be64 tx_errors;
__be64 rx_errors;
__be64 tx_packets;
__be64 rx_packets;
__be64 tx_bytes;
__be64 rx_bytes;
__be64 tx_unicast;
__be64 tx_mcastbcast;
__be64 tx_untagged;
__be64 tx_vlan;
__be64 tx_64_size;
__be64 tx_65_127;
__be64 tx_128_255;
__be64 tx_256_511;
__be64 tx_512_1023;
__be64 tx_1024_1518;
__be64 tx_1519_max;
__be64 rx_unicast;
__be64 rx_mcastbcast;
__be64 rx_untagged;
__be64 rx_vlan;
__be64 rx_64_size;
__be64 rx_65_127;
__be64 rx_128_255;
__be64 rx_256_511;
__be64 rx_512_1023;
__be64 rx_1024_1518;
__be64 rx_1519_max;
__be64 reserved[16];
};
Members
vp_instancevport instance on the OPA port
vesw_idvirtual ethernet switch id
veswport_numvirtual ethernet switch port number
tx_errorstransmit errors
rx_errorsreceive errors
tx_packetstransmit packets
rx_packetsreceive packets
tx_bytestransmit bytes
rx_bytesreceive bytes
tx_unicastunicast packets transmitted
tx_mcastbcastmulticast/broadcast packets transmitted
tx_untaggednon-vlan packets transmitted
tx_vlanvlan packets transmitted
tx_64_sizetransmit packet length is 64 bytes
tx_65_127transmit packet length is >=65 and < 127 bytes
tx_128_255transmit packet length is >=128 and < 255 bytes
tx_256_511transmit packet length is >=256 and < 511 bytes
tx_512_1023transmit packet length is >=512 and < 1023 bytes
tx_1024_1518transmit packet length is >=1024 and < 1518 bytes
tx_1519_maxtransmit packet length >= 1519 bytes
rx_unicastunicast packets received
rx_mcastbcastmulticast/broadcast packets received
rx_untaggednon-vlan packets received
rx_vlanvlan packets received
rx_64_sizereceived packet length is 64 bytes
rx_65_127received packet length is >=65 and < 127 bytes
rx_128_255received packet length is >=128 and < 255 bytes
rx_256_511received packet length is >=256 and < 511 bytes
rx_512_1023received packet length is >=512 and < 1023 bytes
rx_1024_1518received packet length is >=1024 and < 1518 bytes
rx_1519_maxreceived packet length >= 1519 bytes
reservedreserved bytes
Description
All the above are counters of corresponding conditions.
-
struct opa_veswport_error_counters¶
error counters
Definition:
struct opa_veswport_error_counters {
__be16 vp_instance;
__be16 vesw_id;
__be32 veswport_num;
__be64 tx_errors;
__be64 rx_errors;
__be64 rsvd0;
__be64 tx_smac_filt;
__be64 rsvd1;
__be64 rsvd2;
__be64 rsvd3;
__be64 tx_dlid_zero;
__be64 rsvd4;
__be64 tx_logic;
__be64 rsvd5;
__be64 tx_drop_state;
__be64 rx_bad_veswid;
__be64 rsvd6;
__be64 rx_runt;
__be64 rx_oversize;
__be64 rsvd7;
__be64 rx_eth_down;
__be64 rx_drop_state;
__be64 rx_logic;
__be64 rsvd8;
__be64 rsvd9[16];
};
Members
vp_instancevport instance on the OPA port
vesw_idvirtual ethernet switch id
veswport_numvirtual ethernet switch port number
tx_errorstransmit errors
rx_errorsreceive errors
rsvd0reserved bytes
tx_smac_filtsmac filter errors
rsvd1reserved bytes
rsvd2reserved bytes
rsvd3reserved bytes
tx_dlid_zerotransmit packets with invalid dlid
rsvd4reserved bytes
tx_logicother transmit errors
rsvd5reserved bytes
tx_drop_statepacket tansmission in non-forward port state
rx_bad_veswidreceived packet with invalid vesw id
rsvd6reserved bytes
rx_runtreceived ethernet packet with length < 64 bytes
rx_oversizereceived ethernet packet with length > MTU size
rsvd7reserved bytes
rx_eth_downreceived packets when interface is down
rx_drop_statereceived packets in non-forwarding port state
rx_logicother receive errors
rsvd8reserved bytes
rsvd9reserved bytes
Description
All the above are counters of corresponding error conditions.
-
struct opa_veswport_trap¶
Trap message sent to EM by VNIC
Definition:
struct opa_veswport_trap {
__be16 fabric_id;
__be16 veswid;
__be32 veswportnum;
__be16 opaportnum;
u8 veswportindex;
u8 opcode;
__be32 reserved;
};
Members
fabric_id10 bit fabric id
veswid12 bit virtual ethernet switch id
veswportnumlogical port number on the Virtual switch
opaportnumphysical port num (redundant on host)
veswportindexswitch port index on opa port 0 based
opcodeoperation
reserved32 bit for alignment
Description
The VNIC will send trap messages to the Ethernet manager to inform it about changes to the VNIC config, behaviour etc. This is the format of the trap payload.
-
struct opa_vnic_iface_mac_entry¶
single entry in the mac list
Definition:
struct opa_vnic_iface_mac_entry {
u8 mac_addr[ETH_ALEN];
};
Members
mac_addrMAC address
-
struct opa_veswport_iface_macs¶
Msg to set globally administered MAC
Definition:
struct opa_veswport_iface_macs {
__be16 start_idx;
__be16 num_macs_in_msg;
__be16 tot_macs_in_lst;
__be16 gen_count;
struct opa_vnic_iface_mac_entry entry[];
};
Members
start_idxposition of first entry (0 based)
num_macs_in_msgnumber of MACs in this message
tot_macs_in_lstThe total number of MACs the agent has
gen_countgen_count to indicate change
entryThe mac list entry
Description
Same attribute IDS and attribute modifiers as in locally administered addresses used to set globally administered addresses
-
struct opa_vnic_vema_mad¶
Generic VEMA MAD
Definition:
struct opa_vnic_vema_mad {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
u8 reserved;
u8 oui[3];
u8 data[OPA_VNIC_EMA_DATA];
};
Members
mad_hdrGeneric MAD header
rmpp_hdrRMPP header for vendor specific MADs
reservedreserved bytes
ouiUnique org identifier
dataMAD data
-
struct opa_vnic_notice_attr¶
Generic Notice MAD
Definition:
struct opa_vnic_notice_attr {
u8 gen_type;
u8 oui_1;
u8 oui_2;
u8 oui_3;
__be16 trap_num;
__be16 toggle_count;
__be32 issuer_lid;
__be32 reserved;
u8 issuer_gid[16];
u8 raw_data[64];
};
Members
gen_typeGeneric/Specific bit and type of notice
oui_1Vendor ID byte 1
oui_2Vendor ID byte 2
oui_3Vendor ID byte 3
trap_numTrap number
toggle_countNotice toggle bit and count value
issuer_lidTrap issuer’s lid
reservedreserved bytes
issuer_gidIssuer GID (only if Report method)
raw_dataTrap message body
-
struct opa_vnic_vema_mad_trap¶
Generic VEMA MAD Trap
Definition:
struct opa_vnic_vema_mad_trap {
struct ib_mad_hdr mad_hdr;
struct ib_rmpp_hdr rmpp_hdr;
u8 reserved;
u8 oui[3];
struct opa_vnic_notice_attr notice;
};
Members
mad_hdrGeneric MAD header
rmpp_hdrRMPP header for vendor specific MADs
reservedreserved bytes
ouiUnique org identifier
noticeNotice structure
-
void opa_vnic_vema_report_event(struct opa_vnic_adapter *adapter, u8 event)¶
sent trap to report the specified event
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
u8 eventevent to be reported
Description
This function calls vema api to sent a trap for the given event.
-
void opa_vnic_get_summary_counters(struct opa_vnic_adapter *adapter, struct opa_veswport_summary_counters *cntrs)¶
get summary counters
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_veswport_summary_counters *cntrspointer to destination summary counters structure
Description
This function populates the summary counters that is maintained by the given adapter to destination address provided.
-
void opa_vnic_get_error_counters(struct opa_vnic_adapter *adapter, struct opa_veswport_error_counters *cntrs)¶
get error counters
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_veswport_error_counters *cntrspointer to destination error counters structure
Description
This function populates the error counters that is maintained by the given adapter to destination address provided.
-
void opa_vnic_get_vesw_info(struct opa_vnic_adapter *adapter, struct opa_vesw_info *info)¶
Get the vesw information
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_vesw_info *infopointer to destination vesw info structure
Description
This function copies the vesw info that is maintained by the given adapter to destination address provided.
-
void opa_vnic_set_vesw_info(struct opa_vnic_adapter *adapter, struct opa_vesw_info *info)¶
Set the vesw information
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_vesw_info *infopointer to vesw info structure
Description
This function updates the vesw info that is maintained by the given adapter with vesw info provided. Reserved fields are stored and returned back to EM as is.
-
void opa_vnic_get_per_veswport_info(struct opa_vnic_adapter *adapter, struct opa_per_veswport_info *info)¶
Get the vesw per port information
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_per_veswport_info *infopointer to destination vport info structure
Description
This function copies the vesw per port info that is maintained by the given adapter to destination address provided. Note that the read only fields are not copied.
-
void opa_vnic_set_per_veswport_info(struct opa_vnic_adapter *adapter, struct opa_per_veswport_info *info)¶
Set vesw per port information
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_per_veswport_info *infopointer to vport info structure
Description
This function updates the vesw per port info that is maintained by the given adapter with vesw per port info provided. Reserved fields are stored and returned back to EM as is.
-
void opa_vnic_query_mcast_macs(struct opa_vnic_adapter *adapter, struct opa_veswport_iface_macs *macs)¶
query multicast mac list
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_veswport_iface_macs *macspointer mac list
Description
This function populates the provided mac list with the configured multicast addresses in the adapter.
-
void opa_vnic_query_ucast_macs(struct opa_vnic_adapter *adapter, struct opa_veswport_iface_macs *macs)¶
query unicast mac list
Parameters
struct opa_vnic_adapter *adaptervnic port adapter
struct opa_veswport_iface_macs *macspointer mac list
Description
This function populates the provided mac list with the configured unicast addresses in the adapter.
-
struct opa_vnic_vema_port¶
VNIC VEMA port details
Definition:
struct opa_vnic_vema_port {
struct opa_vnic_ctrl_port *cport;
struct ib_mad_agent *mad_agent;
struct opa_class_port_info class_port_info;
u64 tid;
u8 port_num;
struct xarray vports;
struct ib_event_handler event_handler;
struct mutex lock;
};
Members
cportpointer to port
mad_agentpointer to mad agent for port
class_port_infoClass port info information.
tidTransaction id
port_numOPA port number
vportsvnic ports
event_handlerib event handler
lockadapter interface lock
-
u8 vema_get_vport_num(struct opa_vnic_vema_mad *recvd_mad)¶
Get the vnic from the mad
Parameters
struct opa_vnic_vema_mad *recvd_madReceived mad
Return
returns value of the vnic port number
-
struct opa_vnic_adapter *vema_get_vport_adapter(struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_port *port)¶
Get vnic port adapter from recvd mad
Parameters
struct opa_vnic_vema_mad *recvd_madreceived mad
struct opa_vnic_vema_port *portptr to port struct on which MAD was recvd
Return
vnic adapter
-
bool vema_mac_tbl_req_ok(struct opa_veswport_mactable *mac_tbl)¶
Check if mac request has correct values
Parameters
struct opa_veswport_mactable *mac_tblmac table
Description
This function checks for the validity of the offset and number of entries required.
Return
true if offset and num_entries are valid
-
struct opa_vnic_adapter *vema_add_vport(struct opa_vnic_vema_port *port, u8 vport_num)¶
Add a new vnic port
Parameters
struct opa_vnic_vema_port *portptr to opa_vnic_vema_port struct
u8 vport_numvnic port number (to be added)
Description
Return a pointer to the vnic adapter structure
-
void vema_get_class_port_info(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Get class info for port
Parameters
struct opa_vnic_vema_port *portPort on whic MAD was received
struct opa_vnic_vema_mad *recvd_madpointer to the received mad
struct opa_vnic_vema_mad *rsp_madpointer to respose mad
Description
This function copies the latest class port info value set for the port and stores it for generating traps
-
void vema_set_class_port_info(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Get class info for port
Parameters
struct opa_vnic_vema_port *portPort on whic MAD was received
struct opa_vnic_vema_mad *recvd_madpointer to the received mad
struct opa_vnic_vema_mad *rsp_madpointer to respose mad
Description
This function updates the port class info for the specific vnic and sets up the response mad data
-
void vema_get_veswport_info(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Get veswport info
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madpointer to the received mad
struct opa_vnic_vema_mad *rsp_madpointer to respose mad
-
void vema_set_veswport_info(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Set veswport info
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madpointer to the received mad
struct opa_vnic_vema_mad *rsp_madpointer to respose mad
Description
This function gets the port class infor for vnic
-
void vema_get_mac_entries(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Get MAC entries in VNIC MAC table
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madpointer to the received mad
struct opa_vnic_vema_mad *rsp_madpointer to respose mad
Description
This function gets the MAC entries that are programmed into the VNIC MAC forwarding table. It checks for the validity of the index into the MAC table and the number of entries that are to be retrieved.
-
void vema_set_mac_entries(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Set MAC entries in VNIC MAC table
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madpointer to the received mad
struct opa_vnic_vema_mad *rsp_madpointer to respose mad
Description
This function sets the MAC entries in the VNIC forwarding table It checks for the validity of the index and the number of forwarding table entries to be programmed.
-
void vema_set_delete_vesw(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Reset VESW info to POD values
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madpointer to the received mad
struct opa_vnic_vema_mad *rsp_madpointer to respose mad
Description
This function clears all the fields of veswport info for the requested vesw and sets them back to the power-on default values. It does not delete the vesw.
-
void vema_get_mac_list(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad, u16 attr_id)¶
Get the unicast/multicast macs.
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madReceived mad contains fields to set vnic parameters
struct opa_vnic_vema_mad *rsp_madResponse mad to be built
u16 attr_idAttribute ID indicating multicast or unicast mac list
-
void vema_get_summary_counters(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Gets summary counters.
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madReceived mad contains fields to set vnic parameters
struct opa_vnic_vema_mad *rsp_madResponse mad to be built
-
void vema_get_error_counters(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Gets summary counters.
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madReceived mad contains fields to set vnic parameters
struct opa_vnic_vema_mad *rsp_madResponse mad to be built
-
void vema_get(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Process received get MAD
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madReceived mad
struct opa_vnic_vema_mad *rsp_madResponse mad to be built
-
void vema_set(struct opa_vnic_vema_port *port, struct opa_vnic_vema_mad *recvd_mad, struct opa_vnic_vema_mad *rsp_mad)¶
Process received set MAD
Parameters
struct opa_vnic_vema_port *portsource port on which MAD was received
struct opa_vnic_vema_mad *recvd_madReceived mad contains fields to set vnic parameters
struct opa_vnic_vema_mad *rsp_madResponse mad to be built
-
void vema_send(struct ib_mad_agent *mad_agent, struct ib_mad_send_wc *mad_wc)¶
Send handler for VEMA MAD agent
Parameters
struct ib_mad_agent *mad_agentpointer to the mad agent
struct ib_mad_send_wc *mad_wcpointer to mad send work completion information
Description
Free all the data structures associated with the sent MAD
-
void vema_recv(struct ib_mad_agent *mad_agent, struct ib_mad_send_buf *send_buf, struct ib_mad_recv_wc *mad_wc)¶
Recv handler for VEMA MAD agent
Parameters
struct ib_mad_agent *mad_agentpointer to the mad agent
struct ib_mad_send_buf *send_bufSend buffer if found, else NULL
struct ib_mad_recv_wc *mad_wcpointer to mad send work completion information
Description
Handle only set and get methods and respond to other methods as unsupported. Allocate response buffer and address handle for the response MAD.
-
struct opa_vnic_vema_port *vema_get_port(struct opa_vnic_ctrl_port *cport, u8 port_num)¶
Gets the opa_vnic_vema_port
Parameters
struct opa_vnic_ctrl_port *cportpointer to control dev
u8 port_numPort number
Description
This function loops through the ports and returns the opa_vnic_vema port structure that is associated with the OPA port number
Return
- ptr to requested opa_vnic_vema_port strucure
if success, NULL if not
-
void opa_vnic_vema_send_trap(struct opa_vnic_adapter *adapter, struct __opa_veswport_trap *data, u32 lid)¶
This function sends a trap to the EM
Parameters
struct opa_vnic_adapter *adapterpointer to vnic adapter
struct __opa_veswport_trap *datapointer to trap data filled by calling function
u32 lidissuers lid (encap_slid from vesw_port_info)
Description
This function is called from the VNIC driver to send a trap if there is somethng the EM should be notified about. These events currently are 1) UNICAST INTERFACE MACADDRESS changes 2) MULTICAST INTERFACE MACADDRESS changes 3) ETHERNET LINK STATUS changes While allocating the send mad the remote site qpn used is 1 as this is the well known QP.
-
void vema_unregister(struct opa_vnic_ctrl_port *cport)¶
Unregisters agent
Parameters
struct opa_vnic_ctrl_port *cportpointer to control port
Description
This deletes the registration by VEMA for MADs
-
int vema_register(struct opa_vnic_ctrl_port *cport)¶
Registers agent
Parameters
struct opa_vnic_ctrl_port *cportpointer to control port
Description
This function registers the handlers for the VEMA MADs
Return
returns 0 on success. non zero otherwise
-
void opa_vnic_ctrl_config_dev(struct opa_vnic_ctrl_port *cport, bool en)¶
This function sends a trap to the EM by way of ib_modify_port to indicate support for ethernet on the fabric.
Parameters
struct opa_vnic_ctrl_port *cportpointer to control port
bool enenable or disable ethernet on fabric support
-
int opa_vnic_vema_add_one(struct ib_device *device)¶
Handle new ib device
Parameters
struct ib_device *deviceib device pointer
Description
Allocate the vnic control port and initialize it.
-
void opa_vnic_vema_rem_one(struct ib_device *device, void *client_data)¶
Handle ib device removal
Parameters
struct ib_device *deviceib device pointer
void *client_dataib client data
Description
Uninitialize and free the vnic control port.
InfiniBand SCSI RDMA protocol target support¶
-
enum srpt_command_state¶
SCSI command state managed by SRPT
Constants
SRPT_STATE_NEWNew command arrived and is being processed.
SRPT_STATE_NEED_DATAProcessing a write or bidir command and waiting for data arrival.
SRPT_STATE_DATA_INData for the write or bidir command arrived and is being processed.
SRPT_STATE_CMD_RSP_SENTSRP_RSP for SRP_CMD has been sent.
SRPT_STATE_MGMTProcessing a SCSI task management command.
SRPT_STATE_MGMT_RSP_SENTSRP_RSP for SRP_TSK_MGMT has been sent.
SRPT_STATE_DONECommand processing finished successfully, command processing has been aborted or command processing failed.
-
struct srpt_ioctx¶
shared SRPT I/O context information
Definition:
struct srpt_ioctx {
struct ib_cqe cqe;
void *buf;
dma_addr_t dma;
uint32_t offset;
uint32_t index;
};
Members
cqeCompletion queue element.
bufPointer to the buffer.
dmaDMA address of the buffer.
offsetOffset of the first byte in buf and dma that is actually used.
indexIndex of the I/O context in its ioctx_ring array.
-
struct srpt_recv_ioctx¶
SRPT receive I/O context
Definition:
struct srpt_recv_ioctx {
struct srpt_ioctx ioctx;
struct list_head wait_list;
int byte_len;
};
Members
ioctxSee above.
wait_listNode for insertion in srpt_rdma_ch.cmd_wait_list.
byte_lenNumber of bytes in ioctx.buf.
-
struct srpt_send_ioctx¶
SRPT send I/O context
Definition:
struct srpt_send_ioctx {
struct srpt_ioctx ioctx;
struct srpt_rdma_ch *ch;
struct srpt_recv_ioctx *recv_ioctx;
struct srpt_rw_ctx s_rw_ctx;
struct srpt_rw_ctx *rw_ctxs;
struct scatterlist imm_sg;
struct ib_cqe rdma_cqe;
enum srpt_command_state state;
struct se_cmd cmd;
u8 n_rdma;
u8 n_rw_ctx;
bool queue_status_only;
u8 sense_data[TRANSPORT_SENSE_BUFFER];
};
Members
ioctxSee above.
chChannel pointer.
recv_ioctxReceive I/O context associated with this send I/O context. Only used for processing immediate data.
s_rw_ctxrw_ctxs points here if only a single rw_ctx is needed.
rw_ctxsRDMA read/write contexts.
imm_sgScatterlist for immediate data.
rdma_cqeRDMA completion queue element.
stateI/O context state.
cmdTarget core command data structure.
n_rdmaNumber of work requests needed to transfer this ioctx.
n_rw_ctxSize of rw_ctxs array.
queue_status_onlySend a SCSI status back to the initiator but no data.
sense_dataSense data to be sent to the initiator.
-
enum rdma_ch_state¶
SRP channel state
Constants
CH_CONNECTINGQP is in RTR state; waiting for RTU.
CH_LIVEQP is in RTS state.
CH_DISCONNECTINGDREQ has been sent and waiting for DREP or DREQ has been received.
CH_DRAININGDREP has been received or waiting for DREP timed out and last work request has been queued.
CH_DISCONNECTEDLast completion has been received.
-
struct srpt_rdma_ch¶
RDMA channel
Definition:
struct srpt_rdma_ch {
struct srpt_nexus *nexus;
struct ib_qp *qp;
union {
struct {
struct ib_cm_id *cm_id;
} ib_cm;
struct {
struct rdma_cm_id *cm_id;
} rdma_cm;
};
struct ib_cq *cq;
u32 cq_size;
struct ib_cqe zw_cqe;
struct rcu_head rcu;
struct kref kref;
struct completion *closed;
int rq_size;
u32 max_rsp_size;
atomic_t sq_wr_avail;
struct srpt_port *sport;
int max_ti_iu_len;
atomic_t req_lim;
atomic_t req_lim_delta;
u16 imm_data_offset;
spinlock_t spinlock;
enum rdma_ch_state state;
struct kmem_cache *rsp_buf_cache;
struct srpt_send_ioctx **ioctx_ring;
struct kmem_cache *req_buf_cache;
struct srpt_recv_ioctx **ioctx_recv_ring;
struct list_head list;
struct list_head cmd_wait_list;
uint16_t pkey;
bool using_rdma_cm;
bool processing_wait_list;
struct se_session *sess;
u8 sess_name[40];
struct work_struct release_work;
};
Members
nexusI_T nexus this channel is associated with.
qpIB queue pair used for communicating over this channel.
{unnamed_union}anonymous
ib_cmSee below.
ib_cm.cm_idIB CM ID associated with the channel.
rdma_cmSee below.
rdma_cm.cm_idRDMA CM ID associated with the channel.
cqIB completion queue for this channel.
cq_sizeNumber of CQEs in cq.
zw_cqeZero-length write CQE.
rcuRCU head.
krefkref for this channel.
closedCompletion object that will be signaled as soon as a new channel object with the same identity can be created.
rq_sizeIB receive queue size.
max_rsp_sizeMaximum size of an RSP response message in bytes.
sq_wr_availnumber of work requests available in the send queue.
sportpointer to the information of the HCA port used by this channel.
max_ti_iu_lenmaximum target-to-initiator information unit length.
req_limrequest limit: maximum number of requests that may be sent by the initiator without having received a response.
req_lim_deltaNumber of credits not yet sent back to the initiator.
imm_data_offsetOffset from start of SRP_CMD for immediate data.
spinlockProtects free_list and state.
statechannel state. See also
enum rdma_ch_state.rsp_buf_cachekmem_cache for ioctx_ring.
ioctx_ringSend ring.
req_buf_cachekmem_cache for ioctx_recv_ring.
ioctx_recv_ringReceive I/O context ring.
listNode in srpt_nexus.ch_list.
cmd_wait_listList of SCSI commands that arrived before the RTU event. This list contains
struct srpt_ioctxelements and is protected against concurrent modification by the cm_id spinlock.pkeyP_Key of the IB partition for this SRP channel.
using_rdma_cmWhether the RDMA/CM or IB/CM is used for this channel.
processing_wait_listWhether or not cmd_wait_list is being processed.
sessSession information associated with this SRP channel.
sess_nameSession name.
release_workAllows scheduling of srpt_release_channel().
-
struct srpt_nexus¶
I_T nexus
Definition:
struct srpt_nexus {
struct rcu_head rcu;
struct list_head entry;
struct list_head ch_list;
u8 i_port_id[16];
u8 t_port_id[16];
};
Members
rcuRCU head for this data structure.
entrysrpt_port.nexus_list list node.
ch_liststruct srpt_rdma_chlist. Protected by srpt_port.mutex.i_port_id128-bit initiator port identifier copied from SRP_LOGIN_REQ.
t_port_id128-bit target port identifier copied from SRP_LOGIN_REQ.
-
struct srpt_port_attrib¶
attributes for SRPT port
Definition:
struct srpt_port_attrib {
u32 srp_max_rdma_size;
u32 srp_max_rsp_size;
u32 srp_sq_size;
bool use_srq;
};
Members
srp_max_rdma_sizeMaximum size of SRP RDMA transfers for new connections.
srp_max_rsp_sizeMaximum size of SRP response messages in bytes.
srp_sq_sizeShared receive queue (SRQ) size.
use_srqWhether or not to use SRQ.
-
struct srpt_tpg¶
information about a single “target portal group”
Definition:
struct srpt_tpg {
struct list_head entry;
struct srpt_port_id *sport_id;
struct se_portal_group tpg;
};
Members
entryEntry in sport_id->tpg_list.
sport_idPort name this TPG is associated with.
tpgLIO TPG data structure.
Description
Zero or more target portal groups are associated with each port name (srpt_port_id). With each TPG an ACL list is associated.
-
struct srpt_port_id¶
LIO RDMA port information
Definition:
struct srpt_port_id {
struct mutex mutex;
struct list_head tpg_list;
struct se_wwn wwn;
char name[64];
};
Members
mutexProtects tpg_list changes.
tpg_listTPGs associated with the RDMA port name.
wwnWWN associated with the RDMA port name.
nameASCII representation of the port name.
Description
Multiple sysfs directories can be associated with a single RDMA port. This data structure represents a single (port, name) pair.
-
struct srpt_port¶
SRPT RDMA port information
Definition:
struct srpt_port {
struct srpt_device *sdev;
struct ib_mad_agent *mad_agent;
bool enabled;
u8 port;
u32 sm_lid;
u32 lid;
union ib_gid gid;
struct work_struct work;
char guid_name[64];
struct srpt_port_id *guid_id;
char gid_name[64];
struct srpt_port_id *gid_id;
struct srpt_port_attrib port_attrib;
atomic_t refcount;
struct completion *freed_channels;
struct mutex mutex;
struct list_head nexus_list;
};
Members
sdevbackpointer to the HCA information.
mad_agentper-port management datagram processing information.
enabledWhether or not this target port is enabled.
portone-based port number.
sm_lidcached value of the port’s sm_lid.
lidcached value of the port’s lid.
gidcached value of the port’s gid.
workwork structure for refreshing the aforementioned cached values.
guid_nameport name in GUID format.
guid_idLIO target port information for the port name in GUID format.
gid_nameport name in GID format.
gid_idLIO target port information for the port name in GID format.
port_attribPort attributes that can be accessed through configfs.
refcountNumber of objects associated with this port.
freed_channelsCompletion that will be signaled once refcount becomes 0.
mutexProtects nexus_list.
nexus_listNexus list. See also srpt_nexus.entry.
-
struct srpt_device¶
information associated by SRPT with a single HCA
Definition:
struct srpt_device {
struct kref refcnt;
struct ib_device *device;
struct ib_pd *pd;
u32 lkey;
struct ib_srq *srq;
struct ib_cm_id *cm_id;
int srq_size;
struct mutex sdev_mutex;
bool use_srq;
struct kmem_cache *req_buf_cache;
struct srpt_recv_ioctx **ioctx_ring;
struct ib_event_handler event_handler;
struct list_head list;
struct srpt_port port[];
};
Members
refcntReference count for this device.
deviceBackpointer to the struct ib_device managed by the IB core.
pdIB protection domain.
lkeyL_Key (local key) with write access to all local memory.
srqPer-HCA SRQ (shared receive queue).
cm_idConnection identifier.
srq_sizeSRQ size.
sdev_mutexSerializes use_srq changes.
use_srqWhether or not to use SRQ.
req_buf_cachekmem_cache for ioctx_ring buffers.
ioctx_ringPer-HCA SRQ.
event_handlerPer-HCA asynchronous IB event handler.
listNode in srpt_dev_list.
portInformation about the ports owned by this HCA.
-
void srpt_event_handler(struct ib_event_handler *handler, struct ib_event *event)¶
asynchronous IB event callback function
Parameters
struct ib_event_handler *handlerIB event handler registered by
ib_register_event_handler().struct ib_event *eventDescription of the event that occurred.
Description
Callback function called by the InfiniBand core when an asynchronous IB event occurs. This callback may occur in interrupt context. See also section 11.5.2, Set Asynchronous Event Handler in the InfiniBand Architecture Specification.
-
void srpt_srq_event(struct ib_event *event, void *ctx)¶
SRQ event callback function
Parameters
struct ib_event *eventDescription of the event that occurred.
void *ctxContext pointer specified at SRQ creation time.
-
void srpt_qp_event(struct ib_event *event, void *ptr)¶
QP event callback function
Parameters
struct ib_event *eventDescription of the event that occurred.
void *ptrSRPT RDMA channel.
-
void srpt_set_ioc(u8 *c_list, u32 slot, u8 value)¶
initialize a IOUnitInfo structure
Parameters
u8 *c_listcontroller list.
u32 slotone-based slot number.
u8 valuefour-bit value.
Description
Copies the lowest four bits of value in element slot of the array of four bit elements called c_list (controller list). The index slot is one-based.
-
void srpt_get_class_port_info(struct ib_dm_mad *mad)¶
copy ClassPortInfo to a management datagram
Parameters
struct ib_dm_mad *madDatagram that will be sent as response to DM_ATTR_CLASS_PORT_INFO.
Description
See also section 16.3.3.1 ClassPortInfo in the InfiniBand Architecture Specification.
-
void srpt_get_iou(struct ib_dm_mad *mad)¶
write IOUnitInfo to a management datagram
Parameters
struct ib_dm_mad *madDatagram that will be sent as response to DM_ATTR_IOU_INFO.
Description
See also section 16.3.3.3 IOUnitInfo in the InfiniBand Architecture Specification. See also section B.7, table B.6 in the SRP r16a document.
-
void srpt_get_ioc(struct srpt_port *sport, u32 slot, struct ib_dm_mad *mad)¶
write IOControllerprofile to a management datagram
Parameters
struct srpt_port *sportHCA port through which the MAD has been received.
u32 slotSlot number specified in DM_ATTR_IOC_PROFILE query.
struct ib_dm_mad *madDatagram that will be sent as response to DM_ATTR_IOC_PROFILE.
Description
See also section 16.3.3.4 IOControllerProfile in the InfiniBand Architecture Specification. See also section B.7, table B.7 in the SRP r16a document.
-
void srpt_get_svc_entries(u64 ioc_guid, u16 slot, u8 hi, u8 lo, struct ib_dm_mad *mad)¶
write ServiceEntries to a management datagram
Parameters
u64 ioc_guidI/O controller GUID to use in reply.
u16 slotI/O controller number.
u8 hiEnd of the range of service entries to be specified in the reply.
u8 loStart of the range of service entries to be specified in the reply..
struct ib_dm_mad *madDatagram that will be sent as response to DM_ATTR_SVC_ENTRIES.
Description
See also section 16.3.3.5 ServiceEntries in the InfiniBand Architecture Specification. See also section B.7, table B.8 in the SRP r16a document.
-
void srpt_mgmt_method_get(struct srpt_port *sp, struct ib_mad *rq_mad, struct ib_dm_mad *rsp_mad)¶
process a received management datagram
Parameters
struct srpt_port *spHCA port through which the MAD has been received.
struct ib_mad *rq_madreceived MAD.
struct ib_dm_mad *rsp_madresponse MAD.
-
void srpt_mad_send_handler(struct ib_mad_agent *mad_agent, struct ib_mad_send_wc *mad_wc)¶
MAD send completion callback
Parameters
struct ib_mad_agent *mad_agentReturn value of ib_register_mad_agent().
struct ib_mad_send_wc *mad_wcWork completion reporting that the MAD has been sent.
-
void srpt_mad_recv_handler(struct ib_mad_agent *mad_agent, struct ib_mad_send_buf *send_buf, struct ib_mad_recv_wc *mad_wc)¶
MAD reception callback function
Parameters
struct ib_mad_agent *mad_agentReturn value of ib_register_mad_agent().
struct ib_mad_send_buf *send_bufNot used.
struct ib_mad_recv_wc *mad_wcWork completion reporting that a MAD has been received.
Parameters
struct srpt_port *sportSRPT HCA port.
Description
Enable InfiniBand management datagram processing, update the cached sm_lid, lid and gid values, and register a callback function for processing MADs on the specified port.
Note
It is safe to call this function more than once for the same port.
-
void srpt_unregister_mad_agent(struct srpt_device *sdev, int port_cnt)¶
unregister MAD callback functions
Parameters
struct srpt_device *sdevSRPT HCA pointer.
int port_cntnumber of ports with registered MAD
Note
It is safe to call this function more than once for the same device.
-
struct srpt_ioctx *srpt_alloc_ioctx(struct srpt_device *sdev, int ioctx_size, struct kmem_cache *buf_cache, enum dma_data_direction dir)¶
allocate a SRPT I/O context structure
Parameters
struct srpt_device *sdevSRPT HCA pointer.
int ioctx_sizeI/O context size.
struct kmem_cache *buf_cacheI/O buffer cache.
enum dma_data_direction dirDMA data direction.
-
void srpt_free_ioctx(struct srpt_device *sdev, struct srpt_ioctx *ioctx, struct kmem_cache *buf_cache, enum dma_data_direction dir)¶
free a SRPT I/O context structure
Parameters
struct srpt_device *sdevSRPT HCA pointer.
struct srpt_ioctx *ioctxI/O context pointer.
struct kmem_cache *buf_cacheI/O buffer cache.
enum dma_data_direction dirDMA data direction.
-
struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev, int ring_size, int ioctx_size, struct kmem_cache *buf_cache, int alignment_offset, enum dma_data_direction dir)¶
allocate a ring of SRPT I/O context structures
Parameters
struct srpt_device *sdevDevice to allocate the I/O context ring for.
int ring_sizeNumber of elements in the I/O context ring.
int ioctx_sizeI/O context size.
struct kmem_cache *buf_cacheI/O buffer cache.
int alignment_offsetOffset in each ring buffer at which the SRP information unit starts.
enum dma_data_direction dirDMA data direction.
-
void srpt_free_ioctx_ring(struct srpt_ioctx **ioctx_ring, struct srpt_device *sdev, int ring_size, struct kmem_cache *buf_cache, enum dma_data_direction dir)¶
free the ring of SRPT I/O context structures
Parameters
struct srpt_ioctx **ioctx_ringI/O context ring to be freed.
struct srpt_device *sdevSRPT HCA pointer.
int ring_sizeNumber of ring elements.
struct kmem_cache *buf_cacheI/O buffer cache.
enum dma_data_direction dirDMA data direction.
-
enum srpt_command_state srpt_set_cmd_state(struct srpt_send_ioctx *ioctx, enum srpt_command_state new)¶
set the state of a SCSI command
Parameters
struct srpt_send_ioctx *ioctxSend I/O context.
enum srpt_command_state newNew I/O context state.
Description
Does not modify the state of aborted commands. Returns the previous command state.
-
bool srpt_test_and_set_cmd_state(struct srpt_send_ioctx *ioctx, enum srpt_command_state old, enum srpt_command_state new)¶
test and set the state of a command
Parameters
struct srpt_send_ioctx *ioctxSend I/O context.
enum srpt_command_state oldCurrent I/O context state.
enum srpt_command_state newNew I/O context state.
Description
Returns true if and only if the previous command state was equal to ‘old’.
-
int srpt_post_recv(struct srpt_device *sdev, struct srpt_rdma_ch *ch, struct srpt_recv_ioctx *ioctx)¶
post an IB receive request
Parameters
struct srpt_device *sdevSRPT HCA pointer.
struct srpt_rdma_ch *chSRPT RDMA channel.
struct srpt_recv_ioctx *ioctxReceive I/O context pointer.
-
int srpt_zerolength_write(struct srpt_rdma_ch *ch)¶
perform a zero-length RDMA write
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
Description
A quote from the InfiniBand specification: C9-88: For an HCA responder using Reliable Connection service, for each zero-length RDMA READ or WRITE request, the R_Key shall not be validated, even if the request includes Immediate data.
-
int srpt_get_desc_tbl(struct srpt_recv_ioctx *recv_ioctx, struct srpt_send_ioctx *ioctx, struct srp_cmd *srp_cmd, enum dma_data_direction *dir, struct scatterlist **sg, unsigned int *sg_cnt, u64 *data_len, u16 imm_data_offset)¶
parse the data descriptors of a SRP_CMD request
Parameters
struct srpt_recv_ioctx *recv_ioctxI/O context associated with the received command srp_cmd.
struct srpt_send_ioctx *ioctxI/O context that will be used for responding to the initiator.
struct srp_cmd *srp_cmdPointer to the SRP_CMD request data.
enum dma_data_direction *dirPointer to the variable to which the transfer direction will be written.
struct scatterlist **sg[out] scatterlist for the parsed SRP_CMD.
unsigned int *sg_cnt[out] length of sg.
u64 *data_lenPointer to the variable to which the total data length of all descriptors in the SRP_CMD request will be written.
u16 imm_data_offset[in] Offset in SRP_CMD requests at which immediate data starts.
Description
This function initializes ioctx->nrbuf and ioctx->r_bufs.
Returns -EINVAL when the SRP_CMD request contains inconsistent descriptors; -ENOMEM when memory allocation fails and zero upon success.
-
int srpt_init_ch_qp(struct srpt_rdma_ch *ch, struct ib_qp *qp)¶
initialize queue pair attributes
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
struct ib_qp *qpQueue pair pointer.
Description
Initialized the attributes of queue pair ‘qp’ by allowing local write, remote read and remote write. Also transitions ‘qp’ to state IB_QPS_INIT.
-
int srpt_ch_qp_rtr(struct srpt_rdma_ch *ch, struct ib_qp *qp)¶
change the state of a channel to ‘ready to receive’ (RTR)
Parameters
struct srpt_rdma_ch *chchannel of the queue pair.
struct ib_qp *qpqueue pair to change the state of.
Description
Returns zero upon success and a negative value upon failure.
Note
currently a struct ib_qp_attr takes 136 bytes on a 64-bit system. If this structure ever becomes larger, it might be necessary to allocate it dynamically instead of on the stack.
-
int srpt_ch_qp_rts(struct srpt_rdma_ch *ch, struct ib_qp *qp)¶
change the state of a channel to ‘ready to send’ (RTS)
Parameters
struct srpt_rdma_ch *chchannel of the queue pair.
struct ib_qp *qpqueue pair to change the state of.
Description
Returns zero upon success and a negative value upon failure.
Note
currently a struct ib_qp_attr takes 136 bytes on a 64-bit system. If this structure ever becomes larger, it might be necessary to allocate it dynamically instead of on the stack.
-
int srpt_ch_qp_err(struct srpt_rdma_ch *ch)¶
set the channel queue pair state to ‘error’
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
-
struct srpt_send_ioctx *srpt_get_send_ioctx(struct srpt_rdma_ch *ch)¶
obtain an I/O context for sending to the initiator
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
-
int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)¶
abort a SCSI command
Parameters
struct srpt_send_ioctx *ioctxI/O context associated with the SCSI command.
-
void srpt_rdma_read_done(struct ib_cq *cq, struct ib_wc *wc)¶
RDMA read completion callback
Parameters
struct ib_cq *cqCompletion queue.
struct ib_wc *wcWork completion.
Description
XXX: what is now target_execute_cmd used to be asynchronous, and unmapping the data that has been transferred via IB RDMA had to be postponed until the check_stop_free() callback. None of this is necessary anymore and needs to be cleaned up.
-
int srpt_build_cmd_rsp(struct srpt_rdma_ch *ch, struct srpt_send_ioctx *ioctx, u64 tag, int status)¶
build a SRP_RSP response
Parameters
struct srpt_rdma_ch *chRDMA channel through which the request has been received.
struct srpt_send_ioctx *ioctxI/O context associated with the SRP_CMD request. The response will be built in the buffer ioctx->buf points at and hence this function will overwrite the request data.
u64 tagtag of the request for which this response is being generated.
int statusvalue for the STATUS field of the SRP_RSP information unit.
Description
Returns the size in bytes of the SRP_RSP response.
An SRP_RSP response contains a SCSI status or service response. See also section 6.9 in the SRP r16a document for the format of an SRP_RSP response. See also SPC-2 for more information about sense data.
-
int srpt_build_tskmgmt_rsp(struct srpt_rdma_ch *ch, struct srpt_send_ioctx *ioctx, u8 rsp_code, u64 tag)¶
build a task management response
Parameters
struct srpt_rdma_ch *chRDMA channel through which the request has been received.
struct srpt_send_ioctx *ioctxI/O context in which the SRP_RSP response will be built.
u8 rsp_codeRSP_CODE that will be stored in the response.
u64 tagTag of the request for which this response is being generated.
Description
Returns the size in bytes of the SRP_RSP response.
An SRP_RSP response contains a SCSI status or service response. See also section 6.9 in the SRP r16a document for the format of an SRP_RSP response.
-
void srpt_handle_cmd(struct srpt_rdma_ch *ch, struct srpt_recv_ioctx *recv_ioctx, struct srpt_send_ioctx *send_ioctx)¶
process a SRP_CMD information unit
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
struct srpt_recv_ioctx *recv_ioctxReceive I/O context.
struct srpt_send_ioctx *send_ioctxSend I/O context.
-
void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, struct srpt_recv_ioctx *recv_ioctx, struct srpt_send_ioctx *send_ioctx)¶
process a SRP_TSK_MGMT information unit
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
struct srpt_recv_ioctx *recv_ioctxReceive I/O context.
struct srpt_send_ioctx *send_ioctxSend I/O context.
Description
Returns 0 if and only if the request will be processed by the target core.
For more information about SRP_TSK_MGMT information units, see also section 6.7 in the SRP r16a document.
-
bool srpt_handle_new_iu(struct srpt_rdma_ch *ch, struct srpt_recv_ioctx *recv_ioctx)¶
process a newly received information unit
Parameters
struct srpt_rdma_ch *chRDMA channel through which the information unit has been received.
struct srpt_recv_ioctx *recv_ioctxReceive I/O context associated with the information unit.
-
void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc)¶
send completion callback
Parameters
struct ib_cq *cqCompletion queue.
struct ib_wc *wcWork completion.
Note
Although this has not yet been observed during tests, at least in
theory it is possible that the srpt_get_send_ioctx() call invoked by
srpt_handle_new_iu() fails. This is possible because the req_lim_delta
value in each response is set to one, and it is possible that this response
makes the initiator send a new request before the send completion for that
response has been processed. This could e.g. happen if the call to
srpt_put_send_iotcx() is delayed because of a higher priority interrupt or
if IB retransmission causes generation of the send completion to be
delayed. Incoming information units for which srpt_get_send_ioctx() fails
are queued on cmd_wait_list. The code below processes these delayed
requests one at a time.
-
int srpt_create_ch_ib(struct srpt_rdma_ch *ch)¶
create receive and send completion queues
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
-
bool srpt_close_ch(struct srpt_rdma_ch *ch)¶
close a RDMA channel
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
Description
Make sure all resources associated with the channel will be deallocated at an appropriate time.
Returns true if and only if the channel state has been modified into CH_DRAINING.
-
int srpt_cm_req_recv(struct srpt_device *const sdev, struct ib_cm_id *ib_cm_id, struct rdma_cm_id *rdma_cm_id, u8 port_num, __be16 pkey, const struct srp_login_req *req, const char *src_addr)¶
process the event IB_CM_REQ_RECEIVED
Parameters
struct srpt_device *const sdevHCA through which the login request was received.
struct ib_cm_id *ib_cm_idIB/CM connection identifier in case of IB/CM.
struct rdma_cm_id *rdma_cm_idRDMA/CM connection identifier in case of RDMA/CM.
u8 port_numPort through which the REQ message was received.
__be16 pkeyP_Key of the incoming connection.
const struct srp_login_req *reqSRP login request.
const char *src_addrGID (IB/CM) or IP address (RDMA/CM) of the port that submitted the login request.
Description
Ownership of the cm_id is transferred to the target session if this function returns zero. Otherwise the caller remains the owner of cm_id.
-
void srpt_cm_rtu_recv(struct srpt_rdma_ch *ch)¶
process an IB_CM_RTU_RECEIVED or USER_ESTABLISHED event
Parameters
struct srpt_rdma_ch *chSRPT RDMA channel.
Description
An RTU (ready to use) message indicates that the connection has been established and that the recipient may begin transmitting.
-
int srpt_cm_handler(struct ib_cm_id *cm_id, const struct ib_cm_event *event)¶
IB connection manager callback function
Parameters
struct ib_cm_id *cm_idIB/CM connection identifier.
const struct ib_cm_event *eventIB/CM event.
Description
A non-zero return value will cause the caller destroy the CM ID.
Note
srpt_cm_handler() must only return a non-zero value when transferring
ownership of the cm_id to a channel by srpt_cm_req_recv() failed. Returning
a non-zero value in any other case will trigger a race with the
ib_destroy_cm_id() call in srpt_release_channel().
-
void srpt_queue_response(struct se_cmd *cmd)¶
transmit the response to a SCSI command
Parameters
struct se_cmd *cmdSCSI target command.
Description
Callback function called by the TCM core. Must not block since it can be invoked on the context of the IB completion handler.
Parameters
struct srpt_port *sportSRPT HCA port.
-
struct port_and_port_id srpt_lookup_port(const char *name)¶
Look up an RDMA port by name
Parameters
const char *nameASCII port name
Description
Increments the RDMA port reference count if an RDMA port pointer is returned. The caller must drop that reference count by calling srpt_port_put_ref().
-
int srpt_add_one(struct ib_device *device)¶
InfiniBand device addition callback function
Parameters
struct ib_device *deviceDescribes a HCA.
-
void srpt_remove_one(struct ib_device *device, void *client_data)¶
InfiniBand device removal callback function
Parameters
struct ib_device *deviceDescribes a HCA.
void *client_dataThe value passed as the third argument to
ib_set_client_data().
-
void srpt_close_session(struct se_session *se_sess)¶
forcibly close a session
Parameters
struct se_session *se_sessSCSI target session.
Description
Callback function invoked by the TCM core to clean up sessions associated with a node ACL when the user invokes rmdir /sys/kernel/config/target/$driver/$port/$tpg/acls/$i_port_id
-
int srpt_parse_i_port_id(u8 i_port_id[16], const char *name)¶
parse an initiator port ID
Parameters
u8 i_port_id[16]Binary 128-bit port ID.
const char *nameASCII representation of a 128-bit initiator port ID.
-
struct se_portal_group *srpt_make_tpg(struct se_wwn *wwn, const char *name)¶
configfs callback invoked for mkdir /sys/kernel/config/target/$driver/$port/$tpg
Parameters
struct se_wwn *wwnCorresponds to $driver/$port.
const char *name$tpg.
-
void srpt_drop_tpg(struct se_portal_group *tpg)¶
configfs callback invoked for rmdir /sys/kernel/config/target/$driver/$port/$tpg
Parameters
struct se_portal_group *tpgTarget portal group to deregister.
-
struct se_wwn *srpt_make_tport(struct target_fabric_configfs *tf, struct config_group *group, const char *name)¶
configfs callback invoked for mkdir /sys/kernel/config/target/$driver/$port
Parameters
struct target_fabric_configfs *tfNot used.
struct config_group *groupNot used.
const char *name$port.
-
void srpt_drop_tport(struct se_wwn *wwn)¶
configfs callback invoked for rmdir /sys/kernel/config/target/$driver/$port
Parameters
struct se_wwn *wwn$port.
-
int srpt_init_module(void)¶
kernel module initialization
Parameters
voidno arguments
Note
Since ib_register_client() registers callback functions, and since at
least one of these callback functions (srpt_add_one()) calls target core
functions, this driver must be registered with the target core before
ib_register_client() is called.
iSCSI Extensions for RDMA (iSER) target support¶
-
void isert_conn_terminate(struct isert_conn *isert_conn)¶
Initiate connection termination
Parameters
struct isert_conn *isert_connisert connection struct
Notes
In case the connection state is BOUND, move state to TEMINATING and start teardown sequence (rdma_disconnect). In case the connection state is UP, complete flush as well.
Description
This routine must be called with mutex held. Thus it is safe to call multiple times.
-
void isert_put_unsol_pending_cmds(struct iscsit_conn *conn)¶
Drop commands waiting for unsolicitate dataout
Parameters
struct iscsit_conn *conniscsi connection
Description
We might still have commands that are waiting for unsolicited dataouts messages. We must put the extra reference on those before blocking on the target_wait_for_session_cmds