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 D60D54595A; Wed, 11 Sep 2024 04:10:23 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CBF9043278; Wed, 11 Sep 2024 04:08:35 +0200 (CEST) Received: from lf-2-32.ptr.blmpb.com (lf-2-32.ptr.blmpb.com [101.36.218.32]) by mails.dpdk.org (Postfix) with ESMTP id B6FAE43254 for ; Wed, 11 Sep 2024 04:08:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1726020499; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=PHhWLsIwBTxrTJWWWw1HFD2PjSi8/PP65GYgzQ8oFF4=; b=fTLRsSVbP//qyzj7rcKNLibnr3LRtFk/znwLWGqbHLrCXL6xrud9Cy6X1KwCkUNoO5bv/W YQ6bghHmdJ3ixoUnmcVSzg7uCPWDpfgEhHBOrnBCn1YtAQ0jWaWYMGR/D3zCfUZCyq1MiS 7/o3tfhbSRoAcCiqPiae4kxTe43EEdbs1yjlSVwtlXfv31lnqG3Rc11spD6DtC/KWTh/sR DR96q2cyzOgpQVjGR4+PMqfD4qDt93uqjc8MU0Sz9PszP+cKp2fE63K5iJSB44PuXy8eM9 TQ41iC+gBq+ydI/sv3TUYWPMYsnI14SMctA8YMgGvYOVgyzTYPKdLNe0VC95uw== To: Date: Wed, 11 Sep 2024 10:07:38 +0800 X-Lms-Return-Path: Cc: , , "WanRenyong" Message-Id: <20240911020740.3950704-18-wanry@yunsilicon.com> X-Mailer: git-send-email 2.25.1 Content-Type: text/plain; charset=UTF-8 Mime-Version: 1.0 X-Original-From: WanRenyong From: "WanRenyong" Subject: [PATCH v2 17/19] net/xsc: add dev link and MTU ops Content-Transfer-Encoding: 7bit Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Wed, 11 Sep 2024 10:08:17 +0800 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 --- 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 0dc1a63cc5..bc5e827d70 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) { @@ -983,6 +997,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) @@ -994,12 +1041,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 e40b0904b7..788cdfa54a 100644 --- a/drivers/net/xsc/xsc_utils.c +++ b/drivers/net/xsc/xsc_utils.c @@ -321,3 +321,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