RDMA/mana_ib: Implement port parameters
authorKonstantin Taranov <kotaranov@microsoft.com>
Wed, 10 Apr 2024 08:42:28 +0000 (01:42 -0700)
committerLeon Romanovsky <leon@kernel.org>
Tue, 16 Apr 2024 11:28:26 +0000 (14:28 +0300)
Implement port parameters for RNIC:
1) extend query_port() method
2) implement get_link_layer()
3) implement query_pkey()

Only port 1 can store GIDs.

Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com>
Link: https://lore.kernel.org/r/1712738551-22075-4-git-send-email-kotaranov@linux.microsoft.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mana/device.c
drivers/infiniband/hw/mana/main.c
drivers/infiniband/hw/mana/mana_ib.h

index 721e2ab8388fc5bfc35fa004a91f22ec64f34eef..ef04cc48264cddef8b446fb5e0c2dd8aecb2b234 100644 (file)
@@ -29,12 +29,14 @@ static const struct ib_device_ops mana_ib_dev_ops = {
        .destroy_rwq_ind_table = mana_ib_destroy_rwq_ind_table,
        .destroy_wq = mana_ib_destroy_wq,
        .disassociate_ucontext = mana_ib_disassociate_ucontext,
+       .get_link_layer = mana_ib_get_link_layer,
        .get_port_immutable = mana_ib_get_port_immutable,
        .mmap = mana_ib_mmap,
        .modify_qp = mana_ib_modify_qp,
        .modify_wq = mana_ib_modify_wq,
        .query_device = mana_ib_query_device,
        .query_gid = mana_ib_query_gid,
+       .query_pkey = mana_ib_query_pkey,
        .query_port = mana_ib_query_port,
        .reg_user_mr = mana_ib_reg_user_mr,
 
index 344e85f4940d8e246490d5126948078a1aca52d5..b2817c92f1c0e803d143f893da41e2d478dc5f44 100644 (file)
@@ -555,7 +555,42 @@ int mana_ib_query_device(struct ib_device *ibdev, struct ib_device_attr *props,
 int mana_ib_query_port(struct ib_device *ibdev, u32 port,
                       struct ib_port_attr *props)
 {
-       /* This version doesn't return port properties */
+       struct net_device *ndev = mana_ib_get_netdev(ibdev, port);
+
+       if (!ndev)
+               return -EINVAL;
+
+       memset(props, 0, sizeof(*props));
+       props->max_mtu = IB_MTU_4096;
+       props->active_mtu = ib_mtu_int_to_enum(ndev->mtu);
+
+       if (netif_carrier_ok(ndev) && netif_running(ndev)) {
+               props->state = IB_PORT_ACTIVE;
+               props->phys_state = IB_PORT_PHYS_STATE_LINK_UP;
+       } else {
+               props->state = IB_PORT_DOWN;
+               props->phys_state = IB_PORT_PHYS_STATE_DISABLED;
+       }
+
+       props->active_width = IB_WIDTH_4X;
+       props->active_speed = IB_SPEED_EDR;
+       props->pkey_tbl_len = 1;
+       if (port == 1)
+               props->gid_tbl_len = 16;
+
+       return 0;
+}
+
+enum rdma_link_layer mana_ib_get_link_layer(struct ib_device *device, u32 port_num)
+{
+       return IB_LINK_LAYER_ETHERNET;
+}
+
+int mana_ib_query_pkey(struct ib_device *ibdev, u32 port, u16 index, u16 *pkey)
+{
+       if (index != 0)
+               return -EINVAL;
+       *pkey = IB_DEFAULT_PKEY_FULL;
        return 0;
 }
 
index 842f9c63a495b5aa4ec97730171ab905b8cef82f..b9117cbc76297e5cb0bfa62c680aa3c825870101 100644 (file)
@@ -266,4 +266,8 @@ void mana_ib_destroy_eqs(struct mana_ib_dev *mdev);
 int mana_ib_gd_create_rnic_adapter(struct mana_ib_dev *mdev);
 
 int mana_ib_gd_destroy_rnic_adapter(struct mana_ib_dev *mdev);
+
+int mana_ib_query_pkey(struct ib_device *ibdev, u32 port, u16 index, u16 *pkey);
+
+enum rdma_link_layer mana_ib_get_link_layer(struct ib_device *device, u32 port_num);
 #endif