net/ionic: use existing array size macro

Using the RTE_DIM() macro makes the code clearer.

Signed-off-by: Andrew Boyer <aboyer@pensando.io>
This commit is contained in:
Andrew Boyer 2021-01-29 14:44:33 -08:00 committed by Ferruh Yigit
parent e63ae349e1
commit 76276d716b
4 changed files with 19 additions and 35 deletions

View File

@ -87,9 +87,8 @@ void
ionic_dev_cmd_comp(struct ionic_dev *idev, void *mem)
{
union ionic_dev_cmd_comp *comp = mem;
unsigned int i;
uint32_t comp_size = sizeof(comp->words) /
sizeof(comp->words[0]);
uint32_t comp_size = RTE_DIM(comp->words);
uint32_t i;
for (i = 0; i < comp_size; i++)
comp->words[i] = ioread32(&idev->dev_cmd->comp.words[i]);
@ -98,9 +97,8 @@ ionic_dev_cmd_comp(struct ionic_dev *idev, void *mem)
void
ionic_dev_cmd_go(struct ionic_dev *idev, union ionic_dev_cmd *cmd)
{
unsigned int i;
uint32_t cmd_size = sizeof(cmd->words) /
sizeof(cmd->words[0]);
uint32_t cmd_size = RTE_DIM(cmd->words);
uint32_t i;
IONIC_PRINT(DEBUG, "Sending %s (%d) via dev_cmd",
ionic_opcode_to_str(cmd->cmd.opcode), cmd->cmd.opcode);

View File

@ -207,8 +207,7 @@ static const struct rte_ionic_xstats_name_off rte_ionic_xstats_strings[] = {
tx_desc_data_error)},
};
#define IONIC_NB_HW_STATS (sizeof(rte_ionic_xstats_strings) / \
sizeof(rte_ionic_xstats_strings[0]))
#define IONIC_NB_HW_STATS RTE_DIM(rte_ionic_xstats_strings)
static int
ionic_dev_fw_version_get(struct rte_eth_dev *eth_dev,

View File

@ -1824,13 +1824,10 @@ ionic_lif_identify(struct ionic_adapter *adapter)
struct ionic_dev *idev = &adapter->idev;
struct ionic_identity *ident = &adapter->ident;
union ionic_lif_config *cfg = &ident->lif.eth.config;
uint32_t lif_words = RTE_DIM(ident->lif.words);
uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data);
uint32_t i, nwords;
int err;
unsigned int i;
unsigned int lif_words = sizeof(ident->lif.words) /
sizeof(ident->lif.words[0]);
unsigned int cmd_words = sizeof(idev->dev_cmd->data) /
sizeof(idev->dev_cmd->data[0]);
unsigned int nwords;
ionic_dev_cmd_lif_identify(idev, IONIC_LIF_TYPE_CLASSIC,
IONIC_IDENTITY_VERSION_1);

View File

@ -263,15 +263,11 @@ ionic_identify(struct ionic_adapter *adapter)
{
struct ionic_dev *idev = &adapter->idev;
struct ionic_identity *ident = &adapter->ident;
int err = 0;
uint32_t i;
unsigned int nwords;
uint32_t drv_size = sizeof(ident->drv.words) /
sizeof(ident->drv.words[0]);
uint32_t cmd_size = sizeof(idev->dev_cmd->data) /
sizeof(idev->dev_cmd->data[0]);
uint32_t dev_size = sizeof(ident->dev.words) /
sizeof(ident->dev.words[0]);
uint32_t drv_size = RTE_DIM(ident->drv.words);
uint32_t cmd_size = RTE_DIM(idev->dev_cmd->data);
uint32_t dev_size = RTE_DIM(ident->dev.words);
uint32_t i, nwords;
int err;
memset(ident, 0, sizeof(*ident));
@ -323,12 +319,9 @@ ionic_port_identify(struct ionic_adapter *adapter)
{
struct ionic_dev *idev = &adapter->idev;
struct ionic_identity *ident = &adapter->ident;
unsigned int port_words = sizeof(ident->port.words) /
sizeof(ident->port.words[0]);
unsigned int cmd_words = sizeof(idev->dev_cmd->data) /
sizeof(idev->dev_cmd->data[0]);
unsigned int i;
unsigned int nwords;
uint32_t port_words = RTE_DIM(ident->port.words);
uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data);
uint32_t i, nwords;
int err;
ionic_dev_cmd_port_identify(idev);
@ -374,12 +367,9 @@ ionic_port_init(struct ionic_adapter *adapter)
struct ionic_dev *idev = &adapter->idev;
struct ionic_identity *ident = &adapter->ident;
char z_name[RTE_MEMZONE_NAMESIZE];
unsigned int config_words = sizeof(ident->port.config.words) /
sizeof(ident->port.config.words[0]);
unsigned int cmd_words = sizeof(idev->dev_cmd->data) /
sizeof(idev->dev_cmd->data[0]);
unsigned int nwords;
unsigned int i;
uint32_t config_words = RTE_DIM(ident->port.config.words);
uint32_t cmd_words = RTE_DIM(idev->dev_cmd->data);
uint32_t i, nwords;
int err;
if (idev->port_info)