From: Kishore Padmanabha <kishore.padmana...@broadcom.com>

Changed the logic to use device serial number to identify that
different ports belong to same physical card instead of the PCI
domain address.

Fixes: 34a7ff5a920e ("net/bnxt: support multi root capability")
Cc: sta...@dpdk.org

Signed-off-by: Kishore Padmanabha <kishore.padmana...@broadcom.com>
Reviewed-by: Shahaji Bhosle <sbho...@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khapa...@broadcom.com>
---
 drivers/net/bnxt/bnxt.h            |  3 +++
 drivers/net/bnxt/bnxt_hwrm.c       |  1 +
 drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 11 ++++++++---
 drivers/net/bnxt/tf_ulp/bnxt_ulp.h |  2 ++
 4 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index dadd0bd95a..08791b8a17 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -138,6 +138,7 @@
 #define BNXT_NUM_CMPL_DMA_AGGR                 36
 #define BNXT_CMPL_AGGR_DMA_TMR_DURING_INT      50
 #define BNXT_NUM_CMPL_DMA_AGGR_DURING_INT      12
+#define BNXT_DEVICE_SERIAL_NUM_SIZE            8
 
 #define        BNXT_DEFAULT_VNIC_STATE_MASK                    \
        
HWRM_ASYNC_EVENT_CMPL_DEFAULT_VNIC_CHANGE_EVENT_DATA1_DEF_VNIC_STATE_MASK
@@ -863,6 +864,8 @@ struct bnxt {
        uint16_t                num_reps;
        struct bnxt_rep_info    *rep_info;
        uint16_t                *cfa_code_map;
+       /* Device Serial Number */
+       uint8_t                 dsn[BNXT_DEVICE_SERIAL_NUM_SIZE];
        /* Struct to hold adapter error recovery related info */
        struct bnxt_error_recovery_info *recovery_info;
 #define BNXT_MARK_TABLE_SZ     (sizeof(struct bnxt_mark_info)  * 64 * 1024)
diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 82679d1b32..edad84c262 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -863,6 +863,7 @@ static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
                    bp->max_l2_ctx, bp->max_vnics);
        bp->max_stat_ctx = rte_le_to_cpu_16(resp->max_stat_ctx);
        bp->max_mcast_addr = rte_le_to_cpu_32(resp->max_mcast_filters);
+       memcpy(bp->dsn, resp->device_serial_number, sizeof(bp->dsn));
 
        if (BNXT_PF(bp))
                bp->pf->total_vnics = rte_le_to_cpu_16(resp->max_vnics);
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
index 3459140f18..500c177039 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c
@@ -1318,9 +1318,13 @@ ulp_get_session(struct bnxt *bp, struct rte_pci_addr 
*pci_addr)
 
        /* if multi root capability is enabled, then ignore the pci bus id */
        STAILQ_FOREACH(session, &bnxt_ulp_session_list, next) {
-               if (session->pci_info.domain == pci_addr->domain &&
-                   (BNXT_MULTIROOT_EN(bp) ||
-                   session->pci_info.bus == pci_addr->bus)) {
+               if (BNXT_MULTIROOT_EN(bp)) {
+                       if (!memcmp(bp->dsn, session->dsn,
+                                   sizeof(session->dsn))) {
+                               return session;
+                       }
+               } else if (session->pci_info.domain == pci_addr->domain &&
+                          session->pci_info.bus == pci_addr->bus) {
                        return session;
                }
        }
@@ -1364,6 +1368,7 @@ ulp_session_init(struct bnxt *bp,
                        /* Add it to the queue */
                        session->pci_info.domain = pci_addr->domain;
                        session->pci_info.bus = pci_addr->bus;
+                       memcpy(session->dsn, bp->dsn, sizeof(session->dsn));
                        rc = pthread_mutex_init(&session->bnxt_ulp_mutex, NULL);
                        if (rc) {
                                BNXT_TF_DBG(ERR, "mutex create failed\n");
diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h 
b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
index a6ad5c1eaa..92db7751fe 100644
--- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
+++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h
@@ -131,11 +131,13 @@ struct bnxt_ulp_pci_info {
        uint8_t         bus;
 };
 
+#define BNXT_ULP_DEVICE_SERIAL_NUM_SIZE 8
 struct bnxt_ulp_session_state {
        STAILQ_ENTRY(bnxt_ulp_session_state)    next;
        bool                            bnxt_ulp_init;
        pthread_mutex_t                 bnxt_ulp_mutex;
        struct bnxt_ulp_pci_info        pci_info;
+       uint8_t                         dsn[BNXT_ULP_DEVICE_SERIAL_NUM_SIZE];
        struct bnxt_ulp_data            *cfg_data;
        struct tf                       *g_tfp[BNXT_ULP_SESSION_MAX];
        uint32_t                        session_opened[BNXT_ULP_SESSION_MAX];
-- 
2.39.2 (Apple Git-143)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to