]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - include/rdma/ib_verbs.h
IB/core: Add RoCE GID table management
[karo-tx-linux.git] / include / rdma / ib_verbs.h
index c3540da2731f8daeeff54ce9d7cd0749cc81dc82..2de56834a6beffc2f5e27711b09fa06a6334980f 100644 (file)
@@ -65,6 +65,10 @@ union ib_gid {
        } global;
 };
 
+struct ib_gid_attr {
+       struct net_device       *ndev;
+};
+
 enum rdma_node_type {
        /* IB values map to NodeInfo:NodeType. */
        RDMA_NODE_IB_CA         = 1,
@@ -285,7 +289,7 @@ enum ib_port_cap_flags {
        IB_PORT_BOOT_MGMT_SUP                   = 1 << 23,
        IB_PORT_LINK_LATENCY_SUP                = 1 << 24,
        IB_PORT_CLIENT_REG_SUP                  = 1 << 25,
-       IB_PORT_IP_BASED_GIDS                   = 1 << 26
+       IB_PORT_IP_BASED_GIDS                   = 1 << 26,
 };
 
 enum ib_port_width {
@@ -1487,7 +1491,7 @@ struct ib_cache {
        rwlock_t                lock;
        struct ib_event_handler event_handler;
        struct ib_pkey_cache  **pkey_cache;
-       struct ib_gid_cache   **gid_cache;
+       struct ib_gid_table   **gid_cache;
        u8                     *lmc_cache;
 };
 
@@ -1573,9 +1577,47 @@ struct ib_device {
                                                 struct ib_port_attr *port_attr);
        enum rdma_link_layer       (*get_link_layer)(struct ib_device *device,
                                                     u8 port_num);
+       /* When calling get_netdev, the HW vendor's driver should return the
+        * net device of device @device at port @port_num or NULL if such
+        * a net device doesn't exist. The vendor driver should call dev_hold
+        * on this net device. The HW vendor's device driver must guarantee
+        * that this function returns NULL before the net device reaches
+        * NETDEV_UNREGISTER_FINAL state.
+        */
+       struct net_device         *(*get_netdev)(struct ib_device *device,
+                                                u8 port_num);
        int                        (*query_gid)(struct ib_device *device,
                                                u8 port_num, int index,
                                                union ib_gid *gid);
+       /* When calling add_gid, the HW vendor's driver should
+        * add the gid of device @device at gid index @index of
+        * port @port_num to be @gid. Meta-info of that gid (for example,
+        * the network device related to this gid is available
+        * at @attr. @context allows the HW vendor driver to store extra
+        * information together with a GID entry. The HW vendor may allocate
+        * memory to contain this information and store it in @context when a
+        * new GID entry is written to. Params are consistent until the next
+        * call of add_gid or delete_gid. The function should return 0 on
+        * success or error otherwise. The function could be called
+        * concurrently for different ports. This function is only called
+        * when roce_gid_table is used.
+        */
+       int                        (*add_gid)(struct ib_device *device,
+                                             u8 port_num,
+                                             unsigned int index,
+                                             const union ib_gid *gid,
+                                             const struct ib_gid_attr *attr,
+                                             void **context);
+       /* When calling del_gid, the HW vendor's driver should delete the
+        * gid of device @device at gid index @index of port @port_num.
+        * Upon the deletion of a GID entry, the HW vendor must free any
+        * allocated memory. The caller will clear @context afterwards.
+        * This function is only called when roce_gid_table is used.
+        */
+       int                        (*del_gid)(struct ib_device *device,
+                                             u8 port_num,
+                                             unsigned int index,
+                                             void **context);
        int                        (*query_pkey)(struct ib_device *device,
                                                 u8 port_num, u16 index, u16 *pkey);
        int                        (*modify_device)(struct ib_device *device,
@@ -2108,6 +2150,26 @@ static inline size_t rdma_max_mad_size(const struct ib_device *device, u8 port_n
        return device->port_immutable[port_num].max_mad_size;
 }
 
+/**
+ * rdma_cap_roce_gid_table - Check if the port of device uses roce_gid_table
+ * @device: Device to check
+ * @port_num: Port number to check
+ *
+ * RoCE GID table mechanism manages the various GIDs for a device.
+ *
+ * NOTE: if allocating the port's GID table has failed, this call will still
+ * return true, but any RoCE GID table API will fail.
+ *
+ * Return: true if the port uses RoCE GID table mechanism in order to manage
+ * its GIDs.
+ */
+static inline bool rdma_cap_roce_gid_table(const struct ib_device *device,
+                                          u8 port_num)
+{
+       return rdma_protocol_roce(device, port_num) &&
+               device->add_gid && device->del_gid;
+}
+
 int ib_query_gid(struct ib_device *device,
                 u8 port_num, int index, union ib_gid *gid);