[dpdk-dev] [PATCH v2 42/62] net/sfc: add HW switch ID helpers
Andrew Rybchenko
arybchenko at solarflare.com
Tue Oct 20 11:13:22 CEST 2020
From: Ivan Malov <ivan.malov at oktetlabs.ru>
The driver will need a means to figure out relationship between
RTE ethdev instances and underlying HW switch entities. For now,
use board serial number string as a unique HW switch identifier.
Signed-off-by: Ivan Malov <ivan.malov at oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
Reviewed-by: Andy Moreton <amoreton at xilinx.com>
---
drivers/net/sfc/sfc.c | 44 +++++++++++++++++++++++++++++++++++++++++++
drivers/net/sfc/sfc.h | 8 ++++++++
2 files changed, 52 insertions(+)
diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c
index 3b896490f7..a4fe495788 100644
--- a/drivers/net/sfc/sfc.c
+++ b/drivers/net/sfc/sfc.c
@@ -1259,3 +1259,47 @@ sfc_register_logtype(const struct rte_pci_addr *pci_addr,
return ret;
}
+
+struct sfc_hw_switch_id {
+ char board_sn[RTE_SIZEOF_FIELD(efx_nic_board_info_t, enbi_serial)];
+};
+
+int
+sfc_hw_switch_id_init(struct sfc_adapter *sa,
+ struct sfc_hw_switch_id **idp)
+{
+ efx_nic_board_info_t board_info;
+ struct sfc_hw_switch_id *id;
+ int rc;
+
+ if (idp == NULL)
+ return EINVAL;
+
+ id = rte_zmalloc("sfc_hw_switch_id", sizeof(*id), 0);
+ if (id == NULL)
+ return ENOMEM;
+
+ rc = efx_nic_get_board_info(sa->nic, &board_info);
+ if (rc != 0)
+ return rc;
+
+ memcpy(id->board_sn, board_info.enbi_serial, sizeof(id->board_sn));
+
+ *idp = id;
+
+ return 0;
+}
+
+void
+sfc_hw_switch_id_fini(__rte_unused struct sfc_adapter *sa,
+ struct sfc_hw_switch_id *id)
+{
+ rte_free(id);
+}
+
+bool
+sfc_hw_switch_ids_equal(const struct sfc_hw_switch_id *left,
+ const struct sfc_hw_switch_id *right)
+{
+ return strcmp(left->board_sn, right->board_sn) == 0;
+}
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 4b5d687108..ed059e142f 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -403,6 +403,14 @@ int sfc_port_reset_mac_stats(struct sfc_adapter *sa);
int sfc_set_rx_mode(struct sfc_adapter *sa);
int sfc_set_rx_mode_unchecked(struct sfc_adapter *sa);
+struct sfc_hw_switch_id;
+
+int sfc_hw_switch_id_init(struct sfc_adapter *sa,
+ struct sfc_hw_switch_id **idp);
+void sfc_hw_switch_id_fini(struct sfc_adapter *sa,
+ struct sfc_hw_switch_id *idp);
+bool sfc_hw_switch_ids_equal(const struct sfc_hw_switch_id *left,
+ const struct sfc_hw_switch_id *right);
#ifdef __cplusplus
}
--
2.17.1
More information about the dev
mailing list