From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DB9B2A034E; Fri, 29 May 2020 13:49:46 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E41EF1DBD5; Fri, 29 May 2020 13:49:45 +0200 (CEST) Received: from NAM04-CO1-obe.outbound.protection.outlook.com (mail-eopbgr690085.outbound.protection.outlook.com [40.107.69.85]) by dpdk.org (Postfix) with ESMTP id 6295E1DBD0 for ; Fri, 29 May 2020 13:49:43 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kC6vfxFT097lTjiWmvOtbgyRCCXf30tzlHXS+ceI7ZRf5GiiKGCnmXkLzRN6R0nOHsmk8+dVPyBr9pqXJJ6fDyVpy3ESHVzy330jJp9xd027Me2236LpsjrgtKhzZ7rboNTUrx1UwLpItJsbLruT4zqzhLNYNpacMQVInEetSdtHftlLuD0DaKW7JJ7zM3CDZpftMWB7dWClgNPX3by7wkmVmE4D+CZ61YpI9FYO8haIGGlxkYT6sz54P0TjquG3Ktm1etI4kwM6HrwrHmZzf5QvuVmr1osNzSaepOtRXIr/rJr1dDH+xm7Ad9zvUaGYM8HadxzjKsqtqlraAau1ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FiqnD6irkeTum4dVjM8DApgCbsvitJzlwnbIiFK4bpg=; b=FbQS1yiYeiyAC+bsXCdHkxJ1EDeIfHkWoRPk2hDwa3Q5w6M6O0ohn6y/ted8OMLvv732kDE6Inqsf6+EXrUrzr1ZGAQbx3Q4VrHtnVIug6wpEvfqZKLMZt7XlNTEsMHe1sWEcwlHAQDQvm3fIRlm12jkDW/Anz39MdUyg++yQczd+MXNB0VZRNN4j/BBKAwWOuyx1vgpqMiXiAhMInZgLJ5nVj1CuVHMENm3r1WSsXHSA5hJaaOiNeEXdxgWfnPwYX9vHne/1wknmAuT0SLugo2GQL7YUoarSZF4zoSwvNAk++lzAQKBceEao+AqX3SdunhnWe49a2al2kRz8zYbBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FiqnD6irkeTum4dVjM8DApgCbsvitJzlwnbIiFK4bpg=; b=Yphv6oFlpaj827RHpdniE5vrtuAzF4YIfMTnlfG3gHqCqtt4qNMkiyRRNbb8XRluiCL8wLWQ9vefQZB4mCUs3dWBzvOQbHkScJnw27v2KZJ51Sf13B9RX7su1tMwLZMXbKxXomFXriE4B7wiwTKXzRIva2Hn78P6QC5bhlRCHiE= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=amd.com; Received: from MN2PR12MB3021.namprd12.prod.outlook.com (2603:10b6:208:c2::30) by MN2PR12MB4030.namprd12.prod.outlook.com (2603:10b6:208:159::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19; Fri, 29 May 2020 11:49:41 +0000 Received: from MN2PR12MB3021.namprd12.prod.outlook.com ([fe80::64e0:6910:9775:a4a3]) by MN2PR12MB3021.namprd12.prod.outlook.com ([fe80::64e0:6910:9775:a4a3%3]) with mapi id 15.20.3021.031; Fri, 29 May 2020 11:49:41 +0000 From: chandu@amd.com To: dev@dpdk.org Cc: Amaranath.Somalapuram@amd.com Date: Fri, 29 May 2020 17:19:20 +0530 Message-Id: <20200529114920.17179-1-chandu@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200320112914.18620-1-chandu@amd.com> References: <20200320112914.18620-1-chandu@amd.com> Content-Type: text/plain X-ClientProxiedBy: MAXPR0101CA0041.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:d::27) To MN2PR12MB3021.namprd12.prod.outlook.com (2603:10b6:208:c2::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from cae-Wallaby.amd.com (165.204.156.251) by MAXPR0101CA0041.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:d::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3045.19 via Frontend Transport; Fri, 29 May 2020 11:49:39 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.156.251] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: daf9e155-d85c-48bc-53a2-08d803c65f21 X-MS-TrafficTypeDiagnostic: MN2PR12MB4030: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-Forefront-PRVS: 04180B6720 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IQp3peY4rbnQIiRi9ze29ZPaGtKQcFUVCcY+GK/9ifkR4Jpt9jaTwzFJlf6MjN7Uh9ZqooqSygAFTPohlZiCgGQPFUq/Iy1CQ05Snfkw0jpuKkRDFbqDjr5u6Bckrlmfljs6rmwujwbZyB93OxfP7DHnBkov5ee+bvcnwDnMwY1clGSIh9FGvRKcEfVWayJLZntibB7rg/rsWQMzrLJccEmrwfaVHbwxKpV/IKd1zdCDPZhJ5+JZN8zdcuJMlU86WxfJ6U9qFo8/ojinpvCvZL7G/2mJZbPeISZFgmYMjYUCaty7iJZ2Blq5FU82keCbWXKZJAtcaPzQ6DECNtVBWg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MN2PR12MB3021.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(396003)(366004)(346002)(376002)(39860400002)(26005)(956004)(478600001)(9686003)(5660300002)(2616005)(1076003)(52116002)(8936002)(7696005)(16526019)(186003)(8676002)(2906002)(86362001)(6486002)(15650500001)(66476007)(66556008)(66946007)(316002)(83380400001)(36756003)(4326008)(6666004)(6916009); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: LRPtGjUD872w5o+W0/nSPLYsAnHZDSO44/tVjazHSRt9zihLIXuJTU/C2t+e0X6hkNauvEdn5jNbb6X+nW68a6aukcIn+xfTDkfpcM2h0zcWdGBUTNwJPRTbHp679+2aBTAJs0vNyJYmVSH2qXGgMnHIok5CN6m00t8rW4UbjZFJ6s5pRlhd/UucNGJ6qINStLDM0ooo1zUdSv7ji3hPZFPH5IMAnsNL2C84N/k8IQ0zDMzJsUvPcnHhwa5hAGV4L8dhbmfy9hstR/1xmvUhIisYO9iRRlfw8EkRHpuVBGjDOQp0/Pq68kp8RbZJN/YcSlePJwgd0gKyfVXoys+oAKOP2hw+Rm46snCBEuoq5eGdZx0vCgOSxiTpF1r7smdOeNEZ3myENGhOsUbimVR2/ra6aYJCNQLYmIRZiIOqTAZ9est7dgr7CeWodS7qwIoeR1QrgUZ3rdyKCFgoX8f0oh4bm53D80/LxTksqLnv2pjeVewRoj1B1D7iom3tVceg X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: daf9e155-d85c-48bc-53a2-08d803c65f21 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 11:49:41.0590 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: xr4wNr1FOPpc2LCRptSyNzvFrqTKkKKpv/OCxTI9euBbaHgDZ5ZbAvjBG6DBC5aXsUyTufQHfQRSZgbFmmaFhg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4030 Subject: [dpdk-dev] [PATCH v2] net/axgbe: add RSS reta/hash query and update X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Chandu Babu N add support for RSS reta/hash query and update function v2: modification as per Andrew Rybchenko review comments Signed-off-by: Chandu Babu N --- doc/guides/nics/features/axgbe.ini | 2 + drivers/net/axgbe/axgbe_dev.c | 5 +- drivers/net/axgbe/axgbe_ethdev.c | 144 +++++++++++++++++++++++++++++ drivers/net/axgbe/axgbe_ethdev.h | 3 + 4 files changed, 152 insertions(+), 2 deletions(-) diff --git a/doc/guides/nics/features/axgbe.ini b/doc/guides/nics/features/axgbe.ini index 0becaa097..34df0d1ee 100644 --- a/doc/guides/nics/features/axgbe.ini +++ b/doc/guides/nics/features/axgbe.ini @@ -11,6 +11,8 @@ Scattered Rx = Y Promiscuous mode = Y Allmulticast mode = Y RSS hash = Y +RSS key update = Y +RSS reta update = Y CRC offload = Y L3 checksum offload = Y L4 checksum offload = Y diff --git a/drivers/net/axgbe/axgbe_dev.c b/drivers/net/axgbe/axgbe_dev.c index 5f0f19592..af62eae3b 100644 --- a/drivers/net/axgbe/axgbe_dev.c +++ b/drivers/net/axgbe/axgbe_dev.c @@ -614,7 +614,7 @@ static int axgbe_write_rss_reg(struct axgbe_port *pdata, unsigned int type, return -EBUSY; } -static int axgbe_write_rss_hash_key(struct axgbe_port *pdata) +int axgbe_write_rss_hash_key(struct axgbe_port *pdata) { struct rte_eth_rss_conf *rss_conf; unsigned int key_regs = sizeof(pdata->rss_key) / sizeof(u32); @@ -638,7 +638,7 @@ static int axgbe_write_rss_hash_key(struct axgbe_port *pdata) return 0; } -static int axgbe_write_rss_lookup_table(struct axgbe_port *pdata) +int axgbe_write_rss_lookup_table(struct axgbe_port *pdata) { unsigned int i; int ret; @@ -683,6 +683,7 @@ static void axgbe_rss_options(struct axgbe_port *pdata) uint64_t rss_hf; rss_conf = &pdata->eth_dev->data->dev_conf.rx_adv_conf.rss_conf; + pdata->rss_hf = rss_conf->rss_hf; rss_hf = rss_conf->rss_hf; if (rss_hf & (ETH_RSS_IPV4 | ETH_RSS_IPV6)) diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c index 867058845..619250fb0 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -60,6 +60,16 @@ axgbe_dev_xstats_get_names_by_id(struct rte_eth_dev *dev, const uint64_t *ids, unsigned int size); static int axgbe_dev_xstats_reset(struct rte_eth_dev *dev); +static int axgbe_dev_rss_reta_update(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size); +static int axgbe_dev_rss_reta_query(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size); +static int axgbe_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf); +static int axgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf); static int axgbe_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info); static int axgbe_flow_ctrl_get(struct rte_eth_dev *dev, @@ -201,6 +211,10 @@ static const struct eth_dev_ops axgbe_eth_dev_ops = { .xstats_get_names = axgbe_dev_xstats_get_names, .xstats_get_names_by_id = axgbe_dev_xstats_get_names_by_id, .xstats_get_by_id = axgbe_dev_xstats_get_by_id, + .reta_update = axgbe_dev_rss_reta_update, + .reta_query = axgbe_dev_rss_reta_query, + .rss_hash_update = axgbe_dev_rss_hash_update, + .rss_hash_conf_get = axgbe_dev_rss_hash_conf_get, .dev_infos_get = axgbe_dev_info_get, .rx_queue_setup = axgbe_dev_rx_queue_setup, .rx_queue_release = axgbe_dev_rx_queue_release, @@ -450,6 +464,136 @@ axgbe_dev_mac_addr_add(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr, return 0; } +static int +axgbe_dev_rss_reta_update(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct axgbe_port *pdata = dev->data->dev_private; + unsigned int i, idx, shift; + int ret; + + if (!pdata->rss_enable) { + PMD_DRV_LOG(ERR, "RSS not enabled\n"); + return -ENOTSUP; + } + + if (reta_size == 0 || reta_size > AXGBE_RSS_MAX_TABLE_SIZE) { + PMD_DRV_LOG(ERR, "reta_size %d is not supported\n", reta_size); + return -EINVAL; + } + + for (i = 0; i < reta_size; i++) { + idx = i / RTE_RETA_GROUP_SIZE; + shift = i % RTE_RETA_GROUP_SIZE; + if ((reta_conf[idx].mask & (1ULL << shift)) == 0) + continue; + pdata->rss_table[i] = reta_conf[idx].reta[shift]; + } + + /* Program the lookup table */ + ret = axgbe_write_rss_lookup_table(pdata); + return ret; +} + +static int +axgbe_dev_rss_reta_query(struct rte_eth_dev *dev, + struct rte_eth_rss_reta_entry64 *reta_conf, + uint16_t reta_size) +{ + struct axgbe_port *pdata = dev->data->dev_private; + unsigned int i, idx, shift; + + if (!pdata->rss_enable) { + PMD_DRV_LOG(ERR, "RSS not enabled\n"); + return -ENOTSUP; + } + + if (reta_size == 0 || reta_size > AXGBE_RSS_MAX_TABLE_SIZE) { + PMD_DRV_LOG(ERR, "reta_size %d is not supported\n", reta_size); + return -EINVAL; + } + + for (i = 0; i < reta_size; i++) { + idx = i / RTE_RETA_GROUP_SIZE; + shift = i % RTE_RETA_GROUP_SIZE; + if ((reta_conf[idx].mask & (1ULL << shift)) == 0) + continue; + reta_conf[idx].reta[shift] = pdata->rss_table[i]; + } + return 0; +} + +static int +axgbe_dev_rss_hash_update(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct axgbe_port *pdata = dev->data->dev_private; + int ret; + + if (!pdata->rss_enable) { + PMD_DRV_LOG(ERR, "RSS not enabled\n"); + return -ENOTSUP; + } + + if (rss_conf == NULL) { + PMD_DRV_LOG(ERR, "rss_conf value isn't valid\n"); + return -EINVAL; + } + + if (rss_conf->rss_key != NULL && + rss_conf->rss_key_len == AXGBE_RSS_HASH_KEY_SIZE) { + rte_memcpy(pdata->rss_key, rss_conf->rss_key, + AXGBE_RSS_HASH_KEY_SIZE); + /* Program the hash key */ + ret = axgbe_write_rss_hash_key(pdata); + if (ret != 0) + return ret; + } + + pdata->rss_hf = rss_conf->rss_hf & AXGBE_RSS_OFFLOAD; + + if (pdata->rss_hf & (ETH_RSS_IPV4 | ETH_RSS_IPV6)) + AXGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, IP2TE, 1); + if (pdata->rss_hf & + (ETH_RSS_NONFRAG_IPV4_TCP | ETH_RSS_NONFRAG_IPV6_TCP)) + AXGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, TCP4TE, 1); + if (pdata->rss_hf & + (ETH_RSS_NONFRAG_IPV4_UDP | ETH_RSS_NONFRAG_IPV6_UDP)) + AXGMAC_SET_BITS(pdata->rss_options, MAC_RSSCR, UDP4TE, 1); + + /* Set the RSS options */ + AXGMAC_IOWRITE(pdata, MAC_RSSCR, pdata->rss_options); + + return 0; +} + +static int +axgbe_dev_rss_hash_conf_get(struct rte_eth_dev *dev, + struct rte_eth_rss_conf *rss_conf) +{ + struct axgbe_port *pdata = dev->data->dev_private; + + if (!pdata->rss_enable) { + PMD_DRV_LOG(ERR, "RSS not enabled\n"); + return -ENOTSUP; + } + + if (rss_conf == NULL) { + PMD_DRV_LOG(ERR, "rss_conf value isn't valid\n"); + return -EINVAL; + } + + if (rss_conf->rss_key != NULL && + rss_conf->rss_key_len >= AXGBE_RSS_HASH_KEY_SIZE) { + rte_memcpy(rss_conf->rss_key, pdata->rss_key, + AXGBE_RSS_HASH_KEY_SIZE); + } + rss_conf->rss_key_len = AXGBE_RSS_HASH_KEY_SIZE; + rss_conf->rss_hf = pdata->rss_hf; + return 0; +} + static void axgbe_dev_mac_addr_remove(struct rte_eth_dev *dev, uint32_t index) { diff --git a/drivers/net/axgbe/axgbe_ethdev.h b/drivers/net/axgbe/axgbe_ethdev.h index f10ec4a40..cedce5af6 100644 --- a/drivers/net/axgbe/axgbe_ethdev.h +++ b/drivers/net/axgbe/axgbe_ethdev.h @@ -594,6 +594,7 @@ struct axgbe_port { uint32_t rss_table[AXGBE_RSS_MAX_TABLE_SIZE]; uint32_t rss_options; int rss_enable; + uint64_t rss_hf; /* Hardware features of the device */ struct axgbe_hw_features hw_feat; @@ -653,5 +654,7 @@ void axgbe_init_function_ptrs_i2c(struct axgbe_i2c_if *i2c_if); void axgbe_set_mac_addn_addr(struct axgbe_port *pdata, u8 *addr, uint32_t index); void axgbe_set_mac_hash_table(struct axgbe_port *pdata, u8 *addr, bool add); +int axgbe_write_rss_lookup_table(struct axgbe_port *pdata); +int axgbe_write_rss_hash_key(struct axgbe_port *pdata); #endif /* RTE_ETH_AXGBE_H_ */ -- 2.17.1