[dpdk-dev] [PATCH 07/22] net/hns3: add support for some misc operations

Ferruh Yigit ferruh.yigit at intel.com
Fri Aug 30 17:04:00 CEST 2019


On 8/23/2019 2:46 PM, Wei Hu (Xavier) wrote:
> This patch adds the following operations defined in struct eth_dev_ops:
> mtu_set, infos_get and fw_version_get for hns3 PMD driver.
> 
> Signed-off-by: Wei Hu (Xavier) <xavier.huwei at huawei.com>
> Signed-off-by: Chunsong Feng <fengchunsong at huawei.com>
> Signed-off-by: Min Hu (Connor) <humin29 at huawei.com>
> Signed-off-by: Hao Chen <chenhao164 at huawei.com>
> Signed-off-by: Huisong Li <lihuisong at huawei.com>
> ---
>  drivers/net/hns3/hns3_ethdev.c | 137 ++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 136 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/hns3/hns3_ethdev.c b/drivers/net/hns3/hns3_ethdev.c
> index 44e21ac..ced9348 100644
> --- a/drivers/net/hns3/hns3_ethdev.c
> +++ b/drivers/net/hns3/hns3_ethdev.c
> @@ -40,6 +40,8 @@
>  int hns3_logtype_init;
>  int hns3_logtype_driver;
>  
> +static int hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
> +

This forward deceleration is not needed.

>  static int
>  hns3_config_tso(struct hns3_hw *hw, unsigned int tso_mss_min,
>  		unsigned int tso_mss_max)
> @@ -1000,6 +1002,131 @@ hns3_config_mtu(struct hns3_hw *hw, uint16_t mps)
>  }
>  
>  static int
> +hns3_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
> +{
> +	struct hns3_adapter *hns = dev->data->dev_private;
> +	uint32_t frame_size = mtu + HNS3_ETH_OVERHEAD;
> +	struct hns3_hw *hw = &hns->hw;
> +	bool is_jumbo_frame;
> +	int ret;
> +
> +	if (mtu < RTE_ETHER_MIN_MTU || frame_size > HNS3_MAX_FRAME_LEN) {
> +		hns3_err(hw, "Failed to set mtu, mtu(%u) invalid. valid "
> +			 "range: %d~%d", mtu, RTE_ETHER_MIN_MTU, HNS3_MAX_MTU);
> +		return -EINVAL;
> +	}

If 'hns3_dev_infos_get()' sets 'min_mtu' & 'max_mtu' properly, above check will
be done by 'rte_eth_dev_set_mtu()' already.

<...>

> +static void
> +hns3_dev_infos_get(struct rte_eth_dev *eth_dev, struct rte_eth_dev_info *info)
> +{
> +	struct hns3_adapter *hns = eth_dev->data->dev_private;
> +	struct hns3_hw *hw = &hns->hw;
> +
> +	info->max_rx_queues = hw->tqps_num;
> +	info->max_tx_queues = hw->tqps_num;
> +	info->max_rx_pktlen = HNS3_MAX_FRAME_LEN; /* CRC included */
> +	info->min_rx_bufsize = hw->rx_buf_len;
> +	info->max_mac_addrs = HNS3_UC_MACADDR_NUM;
> +	info->max_mtu = info->max_rx_pktlen - HNS3_ETH_OVERHEAD;
> +	info->min_mtu = RTE_ETHER_MIN_MTU;

'RTE_ETHER_MIN_MTU' is default value and can be skipped.

<...>

> @@ -2394,6 +2521,9 @@ hns3_dev_close(struct rte_eth_dev *eth_dev)
>  
>  static const struct eth_dev_ops hns3_eth_dev_ops = {
>  	.dev_close          = hns3_dev_close,
> +	.mtu_set            = hns3_dev_mtu_set,
> +	.dev_infos_get          = hns3_dev_infos_get,
> +	.fw_version_get         = hns3_fw_version_get,

Can you please update .ini file in this patch and mark following features as
supported:
MTU update
FW version




More information about the dev mailing list