From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C740E459C3; Wed, 18 Sep 2024 08:12:08 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BD50B42EDF; Wed, 18 Sep 2024 08:10:25 +0200 (CEST) Received: from lf-1-15.ptr.blmpb.com (lf-1-15.ptr.blmpb.com [103.149.242.15]) by mails.dpdk.org (Postfix) with ESMTP id 6348542ECA for ; Wed, 18 Sep 2024 08:10:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1726639809; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=Rrgtl0bNWELcHZGx6wA8sZQGudFtUYln2SconHm34WE=; b=iQZPippZDVNo3+Z6s1y76XQfUFT5dw6dIYBEt1hnlRzhwW93k7eY4dAE7KM6Zau1R5eX/N e2oT19UYA7oSqlZzVt7XnCEtQbV63mYFah5td+lTC6XNWLKL/GVIjjP/NckiltSEMxgK81 i+i2edStrYThpkbuv6Os00/ZL22jnJPOBV9AOd2AceEWUCEaJTD0WtANMiOGNPtaYH5Wx/ 4UYXn3KFY6KqjkY/3yNxqJCFaziWIeyWYmYjj6bHF8u0fypgn0wlt2Tux3cbC5KIvkNtk+ yy9HYo4BtfzfVLFARTa5Nf0+cnrFNRkDdbRNuHJznF1VWb3U2l1uQ8B5X9Igxg== Cc: , "WanRenyong" Date: Wed, 18 Sep 2024 14:09:34 +0800 Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Wed, 18 Sep 2024 14:10:07 +0800 Content-Type: text/plain; charset=UTF-8 To: From: "WanRenyong" Content-Transfer-Encoding: 7bit X-Mailer: git-send-email 2.25.1 X-Lms-Return-Path: X-Original-From: WanRenyong Subject: [PATCH v3 17/19] net/xsc: add dev link and MTU ops Message-Id: <20240918060936.1231758-18-wanry@yunsilicon.com> Mime-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org XSC PMD does not support update link right now, in order to start device successfully link_update function always return 0. Signed-off-by: WanRenyong --- v3: * change the first letter of the log to uppercase --- doc/guides/nics/features/xsc.ini | 1 + drivers/net/xsc/xsc_ethdev.c | 50 ++++++++++++++++++++++++++++++++ drivers/net/xsc/xsc_utils.c | 23 +++++++++++++++ drivers/net/xsc/xsc_utils.h | 1 + 4 files changed, 75 insertions(+) diff --git a/doc/guides/nics/features/xsc.ini b/doc/guides/nics/features/xsc.ini index 772c6418c4..84c5ff4b6b 100644 --- a/doc/guides/nics/features/xsc.ini +++ b/doc/guides/nics/features/xsc.ini @@ -4,6 +4,7 @@ ; Refer to default.ini for the full list of available PMD features. ; [Features] +MTU update = Y RSS hash = Y RSS key update = Y RSS reta update = Y diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c index d6433d9f59..369eba3d63 100644 --- a/drivers/net/xsc/xsc_ethdev.c +++ b/drivers/net/xsc/xsc_ethdev.c @@ -187,6 +187,20 @@ xsc_ethdev_configure(struct rte_eth_dev *dev) return -rte_errno; } +static int +xsc_ethdev_set_link_down(struct rte_eth_dev *dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + return xsc_link_process(dev, priv->ifindex, IFF_UP); +} + +static int +xsc_ethdev_set_link_up(struct rte_eth_dev *dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + return xsc_link_process(dev, priv->ifindex, ~IFF_UP); +} + static int xsc_init_obj(struct xscdv_obj *obj, uint64_t obj_type) { @@ -984,6 +998,39 @@ xsc_ethdev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t idx, uint16_t desc, return 0; } +static int +xsc_ethdev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + uint16_t get_mtu = 0; + int ret = 0; + + if (priv->eth_type != RTE_ETH_REPRESENTOR_PF) { + priv->mtu = mtu; + return 0; + } + + ret = xsc_get_mtu(&priv->mtu, priv->ifindex); + if (ret) + return ret; + + ret = xsc_set_mtu(mtu, priv->ifindex); + if (ret) + return ret; + + ret = xsc_get_mtu(&get_mtu, priv->ifindex); + if (ret) + return ret; + + if (get_mtu != mtu) { + PMD_DRV_LOG(ERR, "Mtu set to %u failure", mtu); + return -EAGAIN; + } + + priv->mtu = mtu; + return 0; +} + static int xsc_ethdev_link_update(__rte_unused struct rte_eth_dev *dev, __rte_unused int wait_to_complete) @@ -995,12 +1042,15 @@ const struct eth_dev_ops xsc_dev_ops = { .dev_configure = xsc_ethdev_configure, .dev_start = xsc_ethdev_start, .dev_stop = xsc_ethdev_stop, + .dev_set_link_down = xsc_ethdev_set_link_down, + .dev_set_link_up = xsc_ethdev_set_link_up, .dev_close = xsc_ethdev_close, .link_update = xsc_ethdev_link_update, .rx_queue_setup = xsc_ethdev_rx_queue_setup, .tx_queue_setup = xsc_ethdev_tx_queue_setup, .rx_queue_release = xsc_ethdev_rxq_release, .tx_queue_release = xsc_ethdev_txq_release, + .mtu_set = xsc_ethdev_set_mtu, .rss_hash_update = xsc_ethdev_rss_hash_update, .rss_hash_conf_get = xsc_ethdev_rss_hash_conf_get, }; diff --git a/drivers/net/xsc/xsc_utils.c b/drivers/net/xsc/xsc_utils.c index 1059681619..d56661f081 100644 --- a/drivers/net/xsc/xsc_utils.c +++ b/drivers/net/xsc/xsc_utils.c @@ -313,3 +313,26 @@ xsc_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32_t i dev->data->mac_addrs[index] = *mac; return 0; } + +int +xsc_link_process(struct rte_eth_dev *dev __rte_unused, + uint32_t ifindex, unsigned int flags) +{ + struct ifreq request; + struct ifreq *ifr = &request; + char ifname[sizeof(ifr->ifr_name)]; + int ret; + unsigned int keep = ~IFF_UP; + + if (if_indextoname(ifindex, ifname) == NULL) + return -rte_errno; + + ret = xsc_ifreq_by_ifname(ifname, SIOCGIFFLAGS, &request); + if (ret) + return ret; + + request.ifr_flags &= keep; + request.ifr_flags |= flags & ~keep; + + return xsc_ifreq_by_ifname(ifname, SIOCSIFFLAGS, &request); +} diff --git a/drivers/net/xsc/xsc_utils.h b/drivers/net/xsc/xsc_utils.h index 672ba3871e..d9327020cd 100644 --- a/drivers/net/xsc/xsc_utils.h +++ b/drivers/net/xsc/xsc_utils.h @@ -22,5 +22,6 @@ int xsc_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac, uint32 int xsc_get_mtu(uint16_t *mtu, uint32_t ifindex); int xsc_set_mtu(uint16_t mtu, uint32_t ifindex); int xsc_get_mac(uint8_t *mac, uint32_t ifindex); +int xsc_link_process(struct rte_eth_dev *dev, uint32_t ifindex, unsigned int flags); #endif -- 2.25.1