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 A6B93424E7; Mon, 4 Sep 2023 06:59:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 160C940A80; Mon, 4 Sep 2023 06:57:54 +0200 (CEST) Received: from VLXDG1SPAM1.ramaxel.com (email.ramaxel.com [221.4.138.186]) by mails.dpdk.org (Postfix) with ESMTP id 82F09406B4 for ; Mon, 4 Sep 2023 06:57:42 +0200 (CEST) Received: from V12DG1MBS03.ramaxel.local ([172.26.18.33]) by VLXDG1SPAM1.ramaxel.com with ESMTP id 3844vCtR054255; Mon, 4 Sep 2023 12:57:12 +0800 (GMT-8) (envelope-from wanry@3snic.com) Received: from localhost.localdomain (10.64.136.151) by V12DG1MBS03.ramaxel.local (172.26.18.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.17; Mon, 4 Sep 2023 12:57:11 +0800 From: To: CC: , Renyong Wan , Steven Song Subject: [PATCH v5 10/32] net/sssnic: add dev configure and infos get Date: Mon, 4 Sep 2023 12:56:36 +0800 Message-ID: <20230904045658.238185-11-wanry@3snic.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230904045658.238185-1-wanry@3snic.com> References: <20230904045658.238185-1-wanry@3snic.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Originating-IP: [10.64.136.151] X-ClientProxiedBy: V12DG1MBS03.ramaxel.local (172.26.18.33) To V12DG1MBS03.ramaxel.local (172.26.18.33) X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: VLXDG1SPAM1.ramaxel.com 3844vCtR054255 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 From: Renyong Wan Signed-off-by: Steven Song Signed-off-by: Renyong Wan --- drivers/net/sssnic/base/sssnic_api.c | 33 ++++++++++++ drivers/net/sssnic/base/sssnic_api.h | 8 +++ drivers/net/sssnic/base/sssnic_cmd.h | 14 +++++ drivers/net/sssnic/base/sssnic_hw.c | 33 +++++++++++- drivers/net/sssnic/base/sssnic_hw.h | 6 +++ drivers/net/sssnic/sssnic_ethdev.c | 76 ++++++++++++++++++++++++++++ drivers/net/sssnic/sssnic_ethdev.h | 53 +++++++++++++++++++ 7 files changed, 222 insertions(+), 1 deletion(-) diff --git a/drivers/net/sssnic/base/sssnic_api.c b/drivers/net/sssnic/base/sssnic_api.c index 51a59f0f25..bf0859cd63 100644 --- a/drivers/net/sssnic/base/sssnic_api.c +++ b/drivers/net/sssnic/base/sssnic_api.c @@ -100,3 +100,36 @@ sssnic_msix_attr_set(struct sssnic_hw *hw, uint16_t msix_idx, return 0; } + +int +sssnic_capability_get(struct sssnic_hw *hw, struct sssnic_capability *capa) +{ + struct sssnic_capability_get_cmd cmd; + struct sssnic_msg msg; + uint32_t cmd_len; + int ret; + + memset(&cmd, 0, sizeof(cmd)); + cmd_len = sizeof(cmd); + cmd.function = SSSNIC_FUNC_IDX(hw); + sssnic_msg_init(&msg, (uint8_t *)&cmd, cmd_len, + SSSNIC_GET_CAPABILITY_CMD, SSSNIC_MPU_FUNC_IDX, + SSSNIC_CFG_MODULE, SSSNIC_MSG_TYPE_REQ); + ret = sssnic_mbox_send(hw, &msg, (uint8_t *)&cmd, &cmd_len, 0); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to send mbox message, ret=%d", ret); + return ret; + } + if (cmd_len == 0 || cmd.common.status != 0) { + PMD_DRV_LOG(ERR, + "Bad response to SSSNIC_GET_CAPABILITY_CMD, len=%u, status=%u", + cmd_len, cmd.common.status); + return -EIO; + } + + capa->phy_port = cmd.phy_port; + capa->max_num_rxq = cmd.rxq_max_id + 1; + capa->max_num_txq = cmd.txq_max_id + 1; + + return 0; +} diff --git a/drivers/net/sssnic/base/sssnic_api.h b/drivers/net/sssnic/base/sssnic_api.h index 3d54eb826a..8011cc8b0f 100644 --- a/drivers/net/sssnic/base/sssnic_api.h +++ b/drivers/net/sssnic/base/sssnic_api.h @@ -15,9 +15,17 @@ struct sssnic_msix_attr { uint8_t resend_timer; }; +struct sssnic_capability { + uint16_t max_num_txq; + uint16_t max_num_rxq; + uint8_t phy_port; + uint8_t cos; +}; + int sssnic_msix_attr_get(struct sssnic_hw *hw, uint16_t msix_idx, struct sssnic_msix_attr *attr); int sssnic_msix_attr_set(struct sssnic_hw *hw, uint16_t msix_idx, struct sssnic_msix_attr *attr); +int sssnic_capability_get(struct sssnic_hw *hw, struct sssnic_capability *capa); #endif /* _SSSNIC_API_H_ */ diff --git a/drivers/net/sssnic/base/sssnic_cmd.h b/drivers/net/sssnic/base/sssnic_cmd.h index ee9f536ac2..79192affbc 100644 --- a/drivers/net/sssnic/base/sssnic_cmd.h +++ b/drivers/net/sssnic/base/sssnic_cmd.h @@ -18,6 +18,8 @@ enum sssnic_mgmt_cmd_id { SSSNIC_GET_FW_VERSION_CMD = 60, }; +#define SSSNIC_GET_CAPABILITY_CMD 0 + struct sssnic_cmd_common { uint8_t status; uint8_t version; @@ -111,4 +113,16 @@ struct sssnic_msix_ctrl_cmd { uint8_t resvd1[5]; }; +struct sssnic_capability_get_cmd { + struct sssnic_cmd_common common; + uint16_t function; + uint16_t resvd0; + uint8_t resvd1[3]; + uint8_t phy_port; + uint32_t resvd2[16]; + uint16_t txq_max_id; + uint16_t rxq_max_id; + uint32_t resvd3[63]; +}; + #endif /* _SSSNIC_CMD_H_ */ diff --git a/drivers/net/sssnic/base/sssnic_hw.c b/drivers/net/sssnic/base/sssnic_hw.c index 4ca75208af..8f5f556bde 100644 --- a/drivers/net/sssnic/base/sssnic_hw.c +++ b/drivers/net/sssnic/base/sssnic_hw.c @@ -253,6 +253,29 @@ sssnic_msix_attr_init(struct sssnic_hw *hw) return 0; } +static int +sssnic_capability_init(struct sssnic_hw *hw) +{ + struct sssnic_capability cap; + int ret; + + ret = sssnic_capability_get(hw, &cap); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to get sssnic capability"); + return ret; + } + + PMD_DRV_LOG(INFO, + "Initialized capability, physic port:%u, max %u txqs, max %u rxqs", + cap.phy_port, cap.max_num_txq, cap.max_num_rxq); + + hw->phy_port = cap.phy_port; + hw->max_num_rxq = cap.max_num_rxq; + hw->max_num_txq = cap.max_num_txq; + + return 0; +} + static int sssnic_base_init(struct sssnic_hw *hw) { @@ -360,10 +383,18 @@ sssnic_hw_init(struct sssnic_hw *hw) goto ctrlq_init_fail; } + ret = sssnic_capability_init(hw); + if (ret != 0) { + PMD_DRV_LOG(ERR, "Failed to initialize capability"); + goto capbility_init_fail; + } + sssnic_pf_status_set(hw, SSSNIC_PF_STATUS_ACTIVE); - return -EINVAL; + return 0; +capbility_init_fail: + sssnic_ctrlq_shutdown(hw); ctrlq_init_fail: sssnic_mbox_shutdown(hw); mbox_init_fail: diff --git a/drivers/net/sssnic/base/sssnic_hw.h b/drivers/net/sssnic/base/sssnic_hw.h index c1b9539015..5f20a9465d 100644 --- a/drivers/net/sssnic/base/sssnic_hw.h +++ b/drivers/net/sssnic/base/sssnic_hw.h @@ -56,12 +56,18 @@ struct sssnic_hw { struct sssnic_mbox *mbox; struct sssnic_ctrlq *ctrlq; uint8_t num_eventqs; + uint8_t phy_port; uint16_t eth_port_id; + uint16_t max_num_rxq; + uint16_t max_num_txq; }; #define SSSNIC_FUNC_IDX(hw) ((hw)->attr.func_idx) #define SSSNIC_ETH_PORT_ID(hw) ((hw)->eth_port_id) #define SSSNIC_MPU_FUNC_IDX 0x1fff +#define SSSNIC_MAX_NUM_RXQ(hw) ((hw)->max_num_rxq) +#define SSSNIC_MAX_NUM_TXQ(hw) ((hw)->max_num_txq) +#define SSSNIC_PHY_PORT(hw) ((hw)->phy_port) #define SSSNIC_FUNC_TYPE(hw) ((hw)->attr.func_type) #define SSSNIC_AF_FUNC_IDX(hw) ((hw)->attr.af_idx) diff --git a/drivers/net/sssnic/sssnic_ethdev.c b/drivers/net/sssnic/sssnic_ethdev.c index 460ff604aa..2d7ed7d60b 100644 --- a/drivers/net/sssnic/sssnic_ethdev.c +++ b/drivers/net/sssnic/sssnic_ethdev.c @@ -9,6 +9,72 @@ #include "base/sssnic_hw.h" #include "sssnic_ethdev.h" +static int +sssnic_ethdev_infos_get(struct rte_eth_dev *ethdev, + struct rte_eth_dev_info *devinfo) +{ + struct sssnic_netdev *netdev; + + netdev = SSSNIC_ETHDEV_PRIVATE(ethdev); + + devinfo->max_rx_queues = netdev->max_num_rxq; + devinfo->max_tx_queues = netdev->max_num_txq; + + devinfo->max_mtu = SSSNIC_ETHDEV_MAX_MTU; + devinfo->min_mtu = SSSNIC_ETHDEV_MIN_MTU; + devinfo->min_rx_bufsize = SSSNIC_ETHDEV_MIN_RXBUF_SZ; + devinfo->max_rx_pktlen = SSSNIC_ETHDEV_MAX_RXPKT_LEN; + devinfo->max_lro_pkt_size = SSSNIC_ETHDEV_MAX_LRO_PKT_SZ; + + devinfo->max_mac_addrs = SSSNIC_ETHDEV_MAX_NUM_UC_MAC; + + devinfo->rx_queue_offload_capa = 0; + devinfo->tx_queue_offload_capa = 0; + devinfo->rx_offload_capa = SSSNIC_ETHDEV_RX_OFFLOAD_CAPA; + devinfo->tx_offload_capa = SSSNIC_ETHDEV_TX_OFFLOAD_CAPA; + + devinfo->hash_key_size = SSSNIC_ETHDEV_RSS_KEY_SZ; + devinfo->reta_size = SSSNIC_ETHDEV_RSS_RETA_SZ; + devinfo->flow_type_rss_offloads = SSSNIC_ETHDEV_RSS_OFFLOAD_FLOW_TYPES; + + devinfo->rx_desc_lim = (struct rte_eth_desc_lim){ + .nb_max = SSSNIC_ETHDEV_MAX_NUM_Q_DESC, + .nb_min = SSSNIC_ETHDEV_MIN_NUM_Q_DESC, + .nb_align = SSSNIC_ETHDEV_NUM_Q_DESC_ALGIN, + }; + devinfo->tx_desc_lim = (struct rte_eth_desc_lim){ + .nb_max = SSSNIC_ETHDEV_MAX_NUM_Q_DESC, + .nb_min = SSSNIC_ETHDEV_MIN_NUM_Q_DESC, + .nb_align = SSSNIC_ETHDEV_NUM_Q_DESC_ALGIN, + }; + + devinfo->default_rxportconf = (struct rte_eth_dev_portconf){ + .burst_size = SSSNIC_ETHDEV_DEF_BURST_SZ, + .ring_size = SSSNIC_ETHDEV_DEF_RING_SZ, + .nb_queues = SSSNIC_ETHDEV_DEF_NUM_QUEUES, + }; + + devinfo->default_txportconf = (struct rte_eth_dev_portconf){ + .burst_size = SSSNIC_ETHDEV_DEF_BURST_SZ, + .ring_size = SSSNIC_ETHDEV_DEF_RING_SZ, + .nb_queues = SSSNIC_ETHDEV_DEF_NUM_QUEUES, + }; + + return 0; +} + +static int +sssnic_ethdev_configure(struct rte_eth_dev *ethdev) +{ + if (ethdev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG) + ethdev->data->dev_conf.rxmode.offloads |= + RTE_ETH_RX_OFFLOAD_RSS_HASH; + + PMD_DRV_LOG(INFO, "Port %u is configured", ethdev->data->port_id); + + return 0; +} + static void sssnic_ethdev_release(struct rte_eth_dev *ethdev) { @@ -18,6 +84,11 @@ sssnic_ethdev_release(struct rte_eth_dev *ethdev) rte_free(hw); } +static const struct eth_dev_ops sssnic_ethdev_ops = { + .dev_configure = sssnic_ethdev_configure, + .dev_infos_get = sssnic_ethdev_infos_get, +}; + static int sssnic_ethdev_init(struct rte_eth_dev *ethdev) { @@ -47,6 +118,11 @@ sssnic_ethdev_init(struct rte_eth_dev *ethdev) return ret; } + netdev->max_num_rxq = SSSNIC_MAX_NUM_RXQ(hw); + netdev->max_num_txq = SSSNIC_MAX_NUM_TXQ(hw); + + ethdev->dev_ops = &sssnic_ethdev_ops; + return 0; } diff --git a/drivers/net/sssnic/sssnic_ethdev.h b/drivers/net/sssnic/sssnic_ethdev.h index 5d951134cc..70dd43d5c0 100644 --- a/drivers/net/sssnic/sssnic_ethdev.h +++ b/drivers/net/sssnic/sssnic_ethdev.h @@ -5,8 +5,61 @@ #ifndef _SSSNIC_ETHDEV_H_ #define _SSSNIC_ETHDEV_H_ +#define SSSNIC_ETHDEV_MIN_MTU 384 +#define SSSNIC_ETHDEV_MAX_MTU 9600 +#define SSSNIC_ETHDEV_OVERHEAD_LEN \ + (RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + RTE_VLAN_HLEN * 2) +#define SSSNIC_ETHDEV_MIN_FRAME_SZ \ + (SSSNIC_ETHDEV_MIN_MTU + SSSNIC_ETHDEV_OVERHEAD_LEN) +#define SSSNIC_ETHDEV_MAX_FRAME_SZ \ + (SSSNIC_ETHDEV_MAX_MTU + SSSNIC_ETHDEV_OVERHEAD_LEN) + +#define SSSNIC_ETHDEV_MIN_RXBUF_SZ 1024 +#define SSSNIC_ETHDEV_MAX_RXPKT_LEN SSSNIC_ETHDEV_MAX_FRAME_SZ +#define SSSNIC_ETHDEV_MAX_LRO_PKT_SZ 65536 + +#define SSSNIC_ETHDEV_RSS_KEY_SZ 40 +#define SSSNIC_ETHDEV_RSS_RETA_SZ 256 + +#define SSSNIC_ETHDEV_MAX_NUM_Q_DESC 16384 +#define SSSNIC_ETHDEV_MIN_NUM_Q_DESC 128 +#define SSSNIC_ETHDEV_NUM_Q_DESC_ALGIN 1 + +#define SSSNIC_ETHDEV_RX_OFFLOAD_CAPA \ + (RTE_ETH_RX_OFFLOAD_VLAN_STRIP | RTE_ETH_RX_OFFLOAD_VLAN_FILTER | \ + RTE_ETH_RX_OFFLOAD_IPV4_CKSUM | RTE_ETH_RX_OFFLOAD_UDP_CKSUM | \ + RTE_ETH_RX_OFFLOAD_TCP_CKSUM | RTE_ETH_RX_OFFLOAD_SCTP_CKSUM | \ + RTE_ETH_RX_OFFLOAD_SCATTER | RTE_ETH_RX_OFFLOAD_TCP_LRO | \ + RTE_ETH_RX_OFFLOAD_RSS_HASH) + +#define SSSNIC_ETHDEV_TX_OFFLOAD_CAPA \ + (RTE_ETH_TX_OFFLOAD_VLAN_INSERT | RTE_ETH_TX_OFFLOAD_IPV4_CKSUM | \ + RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM | \ + RTE_ETH_TX_OFFLOAD_UDP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_CKSUM | \ + RTE_ETH_TX_OFFLOAD_SCTP_CKSUM | RTE_ETH_TX_OFFLOAD_TCP_TSO | \ + RTE_ETH_TX_OFFLOAD_MULTI_SEGS) + +#define SSSNIC_ETHDEV_RSS_OFFLOAD_FLOW_TYPES \ + (RTE_ETH_RSS_IPV4 | RTE_ETH_RSS_FRAG_IPV4 | \ + RTE_ETH_RSS_NONFRAG_IPV4_OTHER | \ + RTE_ETH_RSS_NONFRAG_IPV4_SCTP | RTE_ETH_RSS_NONFRAG_IPV4_TCP | \ + RTE_ETH_RSS_NONFRAG_IPV4_UDP | RTE_ETH_RSS_IPV6 | \ + RTE_ETH_RSS_NONFRAG_IPV6_OTHER | \ + RTE_ETH_RSS_NONFRAG_IPV6_TCP | RTE_ETH_RSS_NONFRAG_IPV6_UDP | \ + RTE_ETH_RSS_IPV6_EX | RTE_ETH_RSS_IPV6_TCP_EX | \ + RTE_ETH_RSS_IPV6_UDP_EX) + +#define SSSNIC_ETHDEV_DEF_BURST_SZ 32 +#define SSSNIC_ETHDEV_DEF_NUM_QUEUES 1 +#define SSSNIC_ETHDEV_DEF_RING_SZ 1024 + +#define SSSNIC_ETHDEV_MAX_NUM_UC_MAC 128 +#define SSSNIC_ETHDEV_MAX_NUM_MC_MAC 2048 + struct sssnic_netdev { void *hw; + uint16_t max_num_txq; + uint16_t max_num_rxq; }; #define SSSNIC_ETHDEV_PRIVATE(eth_dev) \ -- 2.27.0