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 24C1EA034E; Fri, 29 May 2020 13:34:31 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4316D1DC06; Fri, 29 May 2020 13:34:30 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2069.outbound.protection.outlook.com [40.107.244.69]) by dpdk.org (Postfix) with ESMTP id E93551DB38 for ; Fri, 29 May 2020 13:34:28 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JZ75l5uEc1B9PHbLR92TJR2II0k1gcR0WTKjbogkO87Xm7CApMCTKeHzNB1jsNZeNYFnRw5R3wyz2xSVJ4iiu6lfXKtuDbghbwp/o89GcJlHbTnI/Pu0FYW+DS4H2cJY35fT2GHWFb02xQy5IjvrO0lNVudEkpmToq+GZPM/K7cL7m9K4mQrgKfhusc+v6RqPcB+YFmDEp/2frq3OKv4keKogu26peyDjHwUju2RdPAKK9utc2GlrC3nMsbvEOcqlpsgbUXoic22ZQdZa0DhsvmLfIbnYDrS9WosIrO6cb5wrP/Y7bY/BVVd8IKZqc9Ryh7ZEP90SC5QnvuSuB+Gmg== 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=e4X6KTde8CMlCRssxFw/nyRBgWZMRG7my7pnfVwOYgYEBKhxmpPEVocAIa3XeV1jH7UzrD1KFThqmufkEpenLV3feVZ6Dl33OjddRBmLaqQs8KqtceX6RgQkLgZmlLP/t/xm5J8GceneDy3pEEeqRvRlmbw0MbTeHz1KU5736uofiAmkKYeY5S2Li/VZEZXXviFvWNHDmoL2rgAiNaZMl7B+H1vAKUBbH1YQuIAT245WhxvHIvanye8k7hD0kqhCE+s9Q1fTMdB8HRo5lQ9Gz+ywJJkYeTISKWXNs1jyr6ZrpobnJ73Y5TnOr61xcH5CkW92P4Dkcq9FhWxolWNfrw== 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=YbvnOq2rk1Wgy9r3Y5q8p/3tHhWu9TyOTmAL+OL9IHi0I/0qrMtFvhDMpPqsXZ/S3Z/yDL1fxGr4WvinpCEAZt+coyxsELWO7RMP2v7OvUj9k/EyYkjdMhEEURM3HaxaasbieiV1FQefKbyIviOyYVmSRbWKw1cAZbRADFTeLzo= 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 MN2PR12MB4583.namprd12.prod.outlook.com (2603:10b6:208:26e::7) 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:34:25 +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:34:24 +0000 From: chandu@amd.com To: dev@dpdk.org Cc: Amaranath.Somalapuram@amd.com Date: Fri, 29 May 2020 17:04:02 +0530 Message-Id: <20200529113402.17119-1-chandu@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR0101CA0059.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::21) 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 MA1PR0101CA0059.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::21) 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:34:23 +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: d2c2ce67-d383-40af-5157-08d803c43cf7 X-MS-TrafficTypeDiagnostic: MN2PR12MB4583: 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: EHpkTF2OABzdEp5qc9quNMmLG9E8Lz1G0jHDyVEVBf8mKJI8h3dGpXCBbwArfQPis+tsEi3ln3AmGg6T3omzjG5X7yHcFXhiSpwEpCwUfNyvOBrK4iAWs2I+Wv5VbnpjV0RqTmb7mh0Z3XbzgmotTOSQRd7DGiPr6RIEVBLCC0QRCXPkTVZcm8kNMjTTWLObhmVzZw36FE/aDHYYGXYKBtKKbaXlukn3J0aA7+Rg6l+TuXE+Cs9qVdEqWRIpePjh4ObFAfj8e7rhnHT+UEMGa2LyTd3bANzhXisTfdl7wrX1PejSCQzcTuPnY38Y5vYy+JOBe9Z5BgB+K2UoAmsIOw== 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)(366004)(396003)(346002)(136003)(376002)(39860400002)(15650500001)(8676002)(4326008)(316002)(6486002)(16526019)(83380400001)(6916009)(52116002)(26005)(186003)(2616005)(956004)(7696005)(478600001)(9686003)(8936002)(66946007)(66556008)(36756003)(66476007)(6666004)(5660300002)(2906002)(86362001)(1076003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 4YjOpM8cK0cWuxNu+UO6IIlrgxLrJPjsm9oyGIySM1KHDiklt7yMhz7S1PJmkCDmT/Yq2A1Fb2PKoqC6zV5lT+9q8ZhpqwZIpDNPWHgct/1F6qzpw5FppBwlis/axNxfPqZwhFTtzSadI9QDxk5THCrRZjBtrOQgmk1pJhsN+sE5c3WGvuK9tccZTB61xtyJwT2v/IoSkIKQpryc2wbxO+XsFkUye6gcXdSFMo2ZJCGY0HL+NLLHgSFhkJFSIgbLzR4SWiKxaeuoMQwRli3JcZyOE36WVTqw8a/RC7LMuBy9ZZM5FMPzzlQdMNjfI6mJUanYuLZClOH9h42Gy+aHSrGTzMleogbOwSgtQzozLY4cOqLBsCFEwozAIm1QJxrRAm6NqtUazntes7wmT1vmOdXADOPbaY8qsXtaihLx4TDoZwfGFa4QVlpN0kDgwATVcV63cHSBLcs7r5oXhVIbqDPept86Jg42tVq4v1S95b81Pmae+1Xc/eoZOp/sfwbN X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2c2ce67-d383-40af-5157-08d803c43cf7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 May 2020 11:34:24.7657 (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: cD/zjA49o8/wBTq7t0A2L4lPOMH+QKgyYNbMMu42xc0wZ5aq7BYztIHMtC8SNrpiHrE1W2Qy3h210aRZ7QEj6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4583 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