[dpdk-dev] [PATCH v2 2/3] net/enetc: add ENETC PMD with basic operations

Ferruh Yigit ferruh.yigit at intel.com
Fri Sep 21 15:27:33 CEST 2018


On 9/13/2018 10:42 AM, Gagandeep Singh wrote:
> This patch introduces the enetc PMD with basic
> initialisation functions includes probe, teardown,
> hardware initialisation
> 
> Signed-off-by: Gagandeep Singh <g.singh at nxp.com>
<...>

> @@ -0,0 +1,24 @@
> +# SPDX-License-Identifier: BSD-3-Clause
> +# Copyright 2018 NXP
> +
> +include $(RTE_SDK)/mk/rte.vars.mk
> +
> +#
> +# library name
> +#
> +LIB = librte_pmd_enetc.a
> +
> +CFLAGS += -O3

Can you please add following to catch errors.
 +CFLAGS += $(WERROR_FLAGS)

<...>

> +struct enetc_eth_mac_info {
> +	uint8_t addr[ETH_ADDR_LEN];
> +	uint8_t perm_addr[ETH_ADDR_LEN];
> +	bool get_link_status;

Don't use bool in structures, this is slightly new, please check:
https://patches.dpdk.org/patch/44817/

<...>

> +/*
> + * RX/TX ENETC function prototypes
> + */
> +int enetc_rx_queue_setup(struct rte_eth_dev *dev, uint16_t rx_queue_id,
> +		uint16_t nb_rx_desc, unsigned int socket_id,
> +		const struct rte_eth_rxconf *rx_conf,
> +		struct rte_mempool *mb_pool);
> +
> +int enetc_tx_queue_setup(struct rte_eth_dev *dev, uint16_t tx_queue_id,
> +		uint16_t nb_tx_desc, unsigned int socket_id,
> +		const struct rte_eth_txconf *tx_conf);
> +
> +uint16_t enetc_xmit_pkts(void *txq, struct rte_mbuf **tx_pkts,
> +		uint16_t nb_pkts);
> +uint16_t enetc_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts,
> +		uint16_t nb_pkts);

Should these function declerations be in next patch?

<...>

> +static int
> +enetc_dev_init(struct rte_eth_dev *eth_dev)
> +{
> +	int error = 0, i;
> +	struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
> +	struct enetc_eth_hw *hw =
> +		ENETC_DEV_PRIVATE_TO_HW(eth_dev->data->dev_private);
> +	struct enetc_eth_adapter *adapter =
> +		ENETC_DEV_PRIVATE(eth_dev->data->dev_private);
> +
> +	PMD_INIT_FUNC_TRACE();
> +	eth_dev->dev_ops = &enetc_ops;
> +	eth_dev->rx_pkt_burst = NULL;
> +	eth_dev->tx_pkt_burst = NULL;
> +
> +	rte_eth_copy_pci_info(eth_dev, pci_dev);

Isn't this alredy done by rte_eth_dev_pci_generic_probe() ?

> +
> +	/* Retrieving and storing the HW base address of device */
> +	hw->hw.reg = (void *)pci_dev->mem_resource[0].addr;
> +
> +	adapter->tx_bd_count = MAX_BD_COUNT;
> +	adapter->rx_bd_count = MAX_BD_COUNT;
> +
> +	adapter->num_rx_rings = MAX_RX_RINGS;
> +	adapter->num_tx_rings = MAX_TX_RINGS;
> +
> +	for (i = 0; i < adapter->num_rx_rings; i++) {
> +		adapter->rx_ring[i] = rte_zmalloc(NULL,
> +						sizeof(struct enetc_bdr), 0);
> +		if (!adapter->rx_ring[i]) {
> +			ENETC_PMD_ERR("Failed to allocate RX ring memory");
> +			while (--i >= 0)
> +				rte_free(adapter->rx_ring[i]);
> +			error = -ENOMEM;
> +			goto err_late;
> +		}
> +		adapter->rx_ring[i]->bd_count = adapter->rx_bd_count;
> +	}

There are dev->data->nb_rx_queues & dev->data->nb_tx_queues variables set with
user provided values,
Also there are dev->data->rx_queues & dev->data->tx_queues already allocated by
ethdev according queue numbers.

Why you are not using them but having a private version of them and use them?
<...>

> +static int
> +enetc_dev_uninit(struct rte_eth_dev *eth_dev)

error: unused parameter ‘eth_dev’ [-Werror=unused-parameter]
same is valid for below a few more functions.

<...>

> +static int
> +enetc_hardware_init(struct enetc_eth_hw *hw)
> +{
> +	uint32_t psipmr = 0;
> +
> +	/* Calculating and storing the base HW addresses */
> +	hw->hw.port = hw->hw.reg + ENETC_PORT_BASE;
> +	hw->hw.global = hw->hw.reg + ENETC_GLOBAL_BASE;

error: pointer of type ‘void *’ used in arithmetic [-Werror=pointer-arith]

You will get more of this when warnings enabled (please check above suggested
change on Makefile)

<...>

> +static void
> +enetc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
> +{
> +	struct enetc_eth_adapter *adapter =
> +		ENETC_DEV_PRIVATE(dev->data->dev_private);
> +
> +	dev_info->max_rx_queues = adapter->num_rx_rings;
> +	dev_info->max_tx_queues = adapter->num_tx_rings;
> +	dev_info->max_rx_pktlen = 1500
rte_eth_dev_info_get() also returns dev_info->nb_rx_queues &
dev_info->nb_tx_queues based on dev->data->nb_[r/t]x_queues but that is wrong
for this driver becase it uses different values as number of [r/t]x queues.

This is related to the above comment. Using dev->data->nb_[r/t]x_queues instead
of adapter->num_[r/t]x_rings will fix this.


More information about the dev mailing list