X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fnet%2Fsfc%2Fsfc.c;h=671a166402879d9b8affdca65b1ebf2696132bc7;hb=2b6d6d71a0992220043b2f5c3b885c486e7921b7;hp=3b896490f7fe47397268c81f026aeaf19a1f54c0;hpb=02b234adde7593f012be5bbc462a8eb325f8cf33;p=dpdk.git diff --git a/drivers/net/sfc/sfc.c b/drivers/net/sfc/sfc.c index 3b896490f7..671a166402 100644 --- a/drivers/net/sfc/sfc.c +++ b/drivers/net/sfc/sfc.c @@ -1259,3 +1259,48 @@ 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 strncmp(left->board_sn, right->board_sn, + sizeof(left->board_sn)) == 0; +}