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 F3E5346005; Tue, 7 Jan 2025 03:51:44 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54F4C40E1D; Tue, 7 Jan 2025 03:50:50 +0100 (CET) Received: from lf-2-45.ptr.blmpb.com (lf-2-45.ptr.blmpb.com [101.36.218.45]) by mails.dpdk.org (Postfix) with ESMTP id 6E3F240DDC for ; Tue, 7 Jan 2025 03:50:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=feishu2403070942; d=yunsilicon.com; t=1736218220; h=from:subject: mime-version:from:date:message-id:subject:to:cc:reply-to:content-type: mime-version:in-reply-to:message-id; bh=qUOGRTMbA67LXYGKCi5RgomceiRlN8QqIJpAVcGbnKg=; b=XQjays4Kh9aK2ST0Dfy/el0zHa3xyBY4Q17T063T8Z0fAr8VnUj5yl3+7dNQ5wTI1TsWCG jgTErHVTZJeod0Uqyw4pdamQJOTuWJpy/LIZ0kxAtZwTAEpkOoWVWBjcB23WmOZQspq+0X 86OA6wkcenwXGiz6vWRhDxWN37BhslT3JV25dAVPlgL+QK52UDPzrr8GQv7kkbeR+oZMcY wUmg0QPS0YUtfRUwVnPSb3Ykt/YV6Fw4OSMmrofoEHwk3qI8Y6GSHcbuEEYtySq5l4q9fz SxidUbdd4CZQU82UaZQ8vD6gDoYfqT2HWseVE+8tw5/vmO201EGxvVWkc0Qkfw== Mime-Version: 1.0 X-Lms-Return-Path: Content-Transfer-Encoding: 7bit To: Cc: , , , , , , , , , Date: Tue, 07 Jan 2025 10:50:17 +0800 From: "WanRenyong" Message-Id: <20250107025015.1962467-16-wanry@yunsilicon.com> Content-Type: text/plain; charset=UTF-8 Subject: [PATCH v5 15/15] net/xsc: add ethdev link and MTU ops Received: from ubuntu-liun.yunsilicon.com ([58.34.192.114]) by smtp.feishu.cn with ESMTPS; Tue, 07 Jan 2025 10:50:17 +0800 References: <20250107024939.1962467-1-wanry@yunsilicon.com> In-Reply-To: <20250107024939.1962467-1-wanry@yunsilicon.com> X-Original-From: WanRenyong X-Mailer: git-send-email 2.25.1 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 Implement xsc ethdev link and MTU ops. Signed-off-by: WanRenyong --- doc/guides/nics/features/xsc.ini | 1 + drivers/net/xsc/xsc_dev.c | 33 ++++++++++++++++++ drivers/net/xsc/xsc_dev.h | 4 +++ drivers/net/xsc/xsc_ethdev.c | 60 ++++++++++++++++++++++++++++++++ 4 files changed, 98 insertions(+) diff --git a/doc/guides/nics/features/xsc.ini b/doc/guides/nics/features/xsc.ini index eb88517104..d73cf9d136 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_dev.c b/drivers/net/xsc/xsc_dev.c index 350a1fbc70..c836f2f35a 100644 --- a/drivers/net/xsc/xsc_dev.c +++ b/drivers/net/xsc/xsc_dev.c @@ -62,6 +62,39 @@ xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in, data_out, out_len); } +int +xsc_dev_set_link_up(struct xsc_dev *xdev) +{ + if (xdev->dev_ops->set_link_up == NULL) + return -ENOTSUP; + + return xdev->dev_ops->set_link_up(xdev); +} + +int +xsc_dev_set_link_down(struct xsc_dev *xdev) +{ + if (xdev->dev_ops->set_link_down == NULL) + return -ENOTSUP; + + return xdev->dev_ops->set_link_down(xdev); +} + +int +xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete) +{ + if (xdev->dev_ops->link_update == NULL) + return -ENOTSUP; + + return xdev->dev_ops->link_update(xdev, funcid_type, wait_to_complete); +} + +int +xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu) +{ + return xdev->dev_ops->set_mtu(xdev, mtu); +} + int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac) { diff --git a/drivers/net/xsc/xsc_dev.h b/drivers/net/xsc/xsc_dev.h index 686d3b664d..d661523e13 100644 --- a/drivers/net/xsc/xsc_dev.h +++ b/drivers/net/xsc/xsc_dev.h @@ -158,6 +158,9 @@ struct xsc_dev_ops { int xsc_dev_mailbox_exec(struct xsc_dev *xdev, void *data_in, int in_len, void *data_out, int out_len); void xsc_dev_ops_register(struct xsc_dev_ops *new_ops); +int xsc_dev_set_link_up(struct xsc_dev *xdev); +int xsc_dev_set_link_down(struct xsc_dev *xde); +int xsc_dev_link_update(struct xsc_dev *xdev, uint8_t funcid_type, int wait_to_complete); int xsc_dev_destroy_qp(struct xsc_dev *xdev, void *qp); int xsc_dev_destroy_cq(struct xsc_dev *xdev, void *cq); int xsc_dev_modify_qp_status(struct xsc_dev *xdev, uint32_t qpn, int num, int opcode); @@ -175,6 +178,7 @@ int xsc_dev_repr_ports_probe(struct xsc_dev *xdev, int nb_repr_ports, int max_et int xsc_dev_rss_key_modify(struct xsc_dev *xdev, uint8_t *rss_key, uint8_t rss_key_len); bool xsc_dev_is_vf(struct xsc_dev *xdev); int xsc_dev_qp_set_id_get(struct xsc_dev *xdev, int repr_id); +int xsc_dev_set_mtu(struct xsc_dev *xdev, uint16_t mtu); int xsc_dev_get_mac(struct xsc_dev *xdev, uint8_t *mac); #endif /* _XSC_DEV_H_ */ diff --git a/drivers/net/xsc/xsc_ethdev.c b/drivers/net/xsc/xsc_ethdev.c index 584890aa6f..c1dbdf5be9 100644 --- a/drivers/net/xsc/xsc_ethdev.c +++ b/drivers/net/xsc/xsc_ethdev.c @@ -365,6 +365,41 @@ xsc_ethdev_close(struct rte_eth_dev *dev) return 0; } +static int +xsc_ethdev_set_link_up(struct rte_eth_dev *dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + struct xsc_dev *xdev = priv->xdev; + + return xsc_dev_set_link_up(xdev); +} + +static int +xsc_ethdev_set_link_down(struct rte_eth_dev *dev) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + struct xsc_dev *xdev = priv->xdev; + + return xsc_dev_set_link_down(xdev); +} + +static int +xsc_ethdev_link_update(struct rte_eth_dev *dev, + int wait_to_complete) +{ + struct xsc_ethdev_priv *priv = TO_XSC_ETHDEV_PRIV(dev); + struct xsc_dev *xdev = priv->xdev; + int ret = 0; + + ret = xsc_dev_link_update(xdev, priv->funcid_type, wait_to_complete); + if (ret == 0) { + dev->data->dev_link = xdev->pf_dev_link; + dev->data->dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds & + RTE_ETH_LINK_SPEED_FIXED); + } + return ret; +} + static uint64_t xsc_get_rx_queue_offloads(struct rte_eth_dev *dev) { @@ -504,6 +539,27 @@ 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); + int ret = 0; + + if (priv->eth_type != RTE_ETH_REPRESENTOR_PF) { + priv->mtu = mtu; + return 0; + } + + ret = xsc_dev_set_mtu(priv->xdev, mtu); + if (ret) { + PMD_DRV_LOG(ERR, "Mtu set to %u failure", mtu); + return -EAGAIN; + } + + priv->mtu = mtu; + return 0; +} + static int xsc_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats) { @@ -607,7 +663,10 @@ const struct eth_dev_ops xsc_eth_dev_ops = { .dev_configure = xsc_ethdev_configure, .dev_start = xsc_ethdev_start, .dev_stop = xsc_ethdev_stop, + .dev_set_link_up = xsc_ethdev_set_link_up, + .dev_set_link_down = xsc_ethdev_set_link_down, .dev_close = xsc_ethdev_close, + .link_update = xsc_ethdev_link_update, .stats_get = xsc_ethdev_stats_get, .stats_reset = xsc_ethdev_stats_reset, .dev_infos_get = xsc_ethdev_infos_get, @@ -615,6 +674,7 @@ const struct eth_dev_ops xsc_eth_dev_ops = { .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, }; -- 2.25.1