]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
RDMA/bnxt_re: Add support for mirror vnic
authorSaravanan Vajravel <saravanan.vajravel@broadcom.com>
Fri, 22 Aug 2025 04:07:57 +0000 (09:37 +0530)
committerLeon Romanovsky <leon@kernel.org>
Thu, 11 Sep 2025 06:18:14 +0000 (02:18 -0400)
Added below support:
- Querying the pre-reserved mirror_vnic_id
- Allocating/freeing mirror_vnic
- Configuring mirror vnic to associate it with raw qp

These functions will be used in the subsequent patch in this series.

Signed-off-by: Saravanan Vajravel <saravanan.vajravel@broadcom.com>
Reviewed-by: Kashyap Desai <kashyap.desai@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Link: https://patch.msgid.link/20250822040801.776196-7-kalesh-anakkur.purayil@broadcom.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/bnxt_re/bnxt_re.h
drivers/infiniband/hw/bnxt_re/main.c

index b315e40c2e9dfb00751bce306462a019941435f4..4bf10d7db77bebb0b58eb380712c28581a393802 100644 (file)
@@ -248,6 +248,10 @@ int bnxt_re_assign_pma_port_counters(struct bnxt_re_dev *rdev, struct ib_mad *ou
 int bnxt_re_assign_pma_port_ext_counters(struct bnxt_re_dev *rdev,
                                         struct ib_mad *out_mad);
 
+void bnxt_re_hwrm_free_vnic(struct bnxt_re_dev *rdev);
+int bnxt_re_hwrm_alloc_vnic(struct bnxt_re_dev *rdev);
+int bnxt_re_hwrm_cfg_vnic(struct bnxt_re_dev *rdev, u32 qp_id);
+
 static inline struct device *rdev_to_dev(struct bnxt_re_dev *rdev)
 {
        if (rdev)
index a6ff21aa139a3d880510fe81fe20d89009a8dd1c..a284f762738aa1c8623398c84b1288d7714bda0d 100644 (file)
@@ -540,6 +540,72 @@ static void bnxt_re_fill_fw_msg(struct bnxt_fw_msg *fw_msg, void *msg,
        fw_msg->timeout = timeout;
 }
 
+void bnxt_re_hwrm_free_vnic(struct bnxt_re_dev *rdev)
+{
+       struct bnxt_en_dev *en_dev = rdev->en_dev;
+       struct hwrm_vnic_free_input req = {};
+       struct bnxt_fw_msg fw_msg = {};
+       int rc;
+
+       bnxt_re_init_hwrm_hdr((void *)&req, HWRM_VNIC_FREE);
+
+       req.vnic_id = cpu_to_le32(rdev->mirror_vnic_id);
+       bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), NULL,
+                           0, DFLT_HWRM_CMD_TIMEOUT);
+       rc = bnxt_send_msg(en_dev, &fw_msg);
+       if (rc)
+               ibdev_dbg(&rdev->ibdev,
+                         "Failed to free vnic, rc = %d\n", rc);
+}
+
+int bnxt_re_hwrm_alloc_vnic(struct bnxt_re_dev *rdev)
+{
+       struct bnxt_en_dev *en_dev = rdev->en_dev;
+       struct hwrm_vnic_alloc_output resp = {};
+       struct hwrm_vnic_alloc_input req = {};
+       struct bnxt_fw_msg fw_msg = {};
+       int rc;
+
+       bnxt_re_init_hwrm_hdr((void *)&req, HWRM_VNIC_ALLOC);
+
+       req.vnic_id = cpu_to_le16(rdev->mirror_vnic_id);
+       req.flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_VNIC_ID_VALID);
+       bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), (void *)&resp,
+                           sizeof(resp), DFLT_HWRM_CMD_TIMEOUT);
+       rc = bnxt_send_msg(en_dev, &fw_msg);
+       if (rc)
+               ibdev_dbg(&rdev->ibdev,
+                         "Failed to alloc vnic, rc = %d\n", rc);
+
+       return rc;
+}
+
+int bnxt_re_hwrm_cfg_vnic(struct bnxt_re_dev *rdev, u32 qp_id)
+{
+       struct bnxt_en_dev *en_dev = rdev->en_dev;
+       struct hwrm_vnic_cfg_input req = {};
+       struct bnxt_fw_msg fw_msg = {};
+       int rc;
+
+       bnxt_re_init_hwrm_hdr((void *)&req, HWRM_VNIC_CFG);
+
+       req.flags = cpu_to_le32(VNIC_CFG_REQ_FLAGS_ROCE_ONLY_VNIC_MODE);
+       req.enables = cpu_to_le32(VNIC_CFG_REQ_ENABLES_RAW_QP_ID |
+                                 VNIC_CFG_REQ_ENABLES_MRU);
+       req.vnic_id = cpu_to_le16(rdev->mirror_vnic_id);
+       req.raw_qp_id = cpu_to_le32(qp_id);
+       req.mru = cpu_to_le16(rdev->netdev->mtu + VLAN_ETH_HLEN);
+
+       bnxt_re_fill_fw_msg(&fw_msg, (void *)&req, sizeof(req), NULL,
+                           0, DFLT_HWRM_CMD_TIMEOUT);
+       rc = bnxt_send_msg(en_dev, &fw_msg);
+       if (rc)
+               ibdev_dbg(&rdev->ibdev,
+                         "Failed to cfg vnic, rc = %d\n", rc);
+
+       return rc;
+}
+
 /* Query device config using common hwrm */
 static int bnxt_re_hwrm_qcfg(struct bnxt_re_dev *rdev, u32 *db_len,
                             u32 *offset)
@@ -558,6 +624,7 @@ static int bnxt_re_hwrm_qcfg(struct bnxt_re_dev *rdev, u32 *db_len,
        if (!rc) {
                *db_len = PAGE_ALIGN(le16_to_cpu(resp.l2_doorbell_bar_size_kb) * 1024);
                *offset = PAGE_ALIGN(le16_to_cpu(resp.legacy_l2_db_size_kb) * 1024);
+               rdev->mirror_vnic_id = le16_to_cpu(resp.mirror_vnic_id);
        }
        return rc;
 }