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 8E44FA0583; Fri, 20 Mar 2020 12:29:37 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E5C1E2BB9; Fri, 20 Mar 2020 12:29:36 +0100 (CET) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2044.outbound.protection.outlook.com [40.107.237.44]) by dpdk.org (Postfix) with ESMTP id 2AE33F94 for ; Fri, 20 Mar 2020 12:29:36 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Xvb2B+Jeb0FyYJamgWt7YJ8+xVj71WnTRfY9CnafmaSA37jMJPPoAb1QoKEt7f+9Mw5utJ4vksazqv94dejYdSz1WELoJ68zZuV/jr2ty5K83QLq60QIvTQqNpEtMAJD5gEcbHEqB7Y5ttDC0MK0jW2ifRl8BwG9HaqtzUbxpALLbi2UPU0L3vsv04p7NUFPm7Z4WQbXIJ9DJa0jqwW2suHQaHwe6eAVPL6QQ6zf8ZyjysS2bfR0lXm1PrtWRseX9tBXUjpheNXdBhoih45HIJlCeBHHGAHyO3wiNYbXCiKxeDrlIJo3ZBYGvgyDQBpvL0QPHQTFfiGpqg40hdNeuw== 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=JmsyyokR2oBNtiB+oVWbGxkK17AsXLSxz2V7SUQDxK4=; b=WmUaxY3amvza6z6Q4bV+O0p9zj8pLWn79EYOZ3TLu7OydYCJ6nU64hcPCPfcXgbfKmlaFpOSoOg2sTm2oIc6ZF/XnqB0IfM2bddBefkSziVPV9XEZ6kY19YRl6D5tC4E0xLB+x4GEuSfjh9Le7QZ4MFAwXl7ABbefdHAKHr7FFeOE9mYnT47gLGKKynDrPjRyb9O0jxW8oJyaw59fjdLmo/CEUlImHH0ofkKHH2gc3Y8Y0S9SlykVX2gwggPkniwC3DVfsuuBUO100a8gEXENgopM0hmUR/OOMK3KQVZjQGyWBQ77hqzeFdwsefjaD/Na90UBsWz1Xej4wWEZMirUQ== 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=JmsyyokR2oBNtiB+oVWbGxkK17AsXLSxz2V7SUQDxK4=; b=lgn1yUK8pf1Vat0OoIhuaEdqFK00/XzTr+LH118ZU9R2wEcrrBtumJwITHu0qEoNvKfMU4zLrixx2X/8/OoL/SjEuAgr/ZbIjMYYDih5m41YpwsBSvbYvmxGbHUq/YZIlVzEATwfMw+cuTI37knWiyARRPB8VDPbamYi6D8oBps= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=chandu@amd.com; Received: from MN2PR12MB3021.namprd12.prod.outlook.com (2603:10b6:208:c2::30) by MN2PR12MB4062.namprd12.prod.outlook.com (2603:10b6:208:1d0::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2814.22; Fri, 20 Mar 2020 11:29:34 +0000 Received: from MN2PR12MB3021.namprd12.prod.outlook.com ([fe80::31ea:b07d:eb37:203]) by MN2PR12MB3021.namprd12.prod.outlook.com ([fe80::31ea:b07d:eb37:203%7]) with mapi id 15.20.2814.021; Fri, 20 Mar 2020 11:29:34 +0000 From: chandu@amd.com To: dev@dpdk.org Cc: Ravi1.Kumar@amd.com, Amaranath.Somalapuram@amd.com Date: Fri, 20 Mar 2020 16:59:14 +0530 Message-Id: <20200320112914.18620-1-chandu@amd.com> X-Mailer: git-send-email 2.17.1 Content-Type: text/plain X-ClientProxiedBy: MA1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::26) 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 MA1PR0101CA0064.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 11:29:32 +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: db243527-5305-4d5e-2581-08d7ccc1f6c9 X-MS-TrafficTypeDiagnostic: MN2PR12MB4062:|MN2PR12MB4062: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-Forefront-PRVS: 03484C0ABF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(376002)(346002)(396003)(366004)(136003)(199004)(86362001)(2906002)(956004)(1076003)(66946007)(478600001)(4326008)(26005)(2616005)(8936002)(316002)(5660300002)(186003)(8676002)(81166006)(81156014)(9686003)(52116002)(66556008)(6916009)(6486002)(6666004)(7696005)(66476007)(36756003)(16526019); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR12MB4062; H:MN2PR12MB3021.namprd12.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5FuiMAg0zqHVUi5ym2ngsnB8xtvCitV78y//2mAFJuhnYkiUGP9DMQ9sDdD0m7zUA8KVscRhcaUEHboGFIQ6OBIMNGk7w/GoUKZfBa9l7Bw6z9VISvUzZuGlNet6yrNwfx2Dmai4HeZqNt5jdtPKeeU0EZb0bilFycdBu5qFE6emGoQPp13QzK01ac08+QgeDU681YaxXWb4yM5ktqyzQ7Q5nPFstESp8f/kvvAIDum3ipDX1XF1CDQqzwnQIQBFbyxzfFshNBaGhDk1EhN4VzuznK/HRTug8mWoWH+nbB5uR4qnVc/F3EMr3WyXMXKY3T3/sSUj+i6shVajBZ9dUnjXRUoiOGTxc0mRS7fIzHtebrb1g+Fin/UzLlQody8cvzDJqR8Udmf0VbejV7t3NUglEIJKRCRO+b0onnVp1vV7I+WFAMAdK/W6z+kzrO2c X-MS-Exchange-AntiSpam-MessageData: cNuCY7Z2dlp8pn50ZzNc0tNISZYPvKTsh4CnprywJNLOGYwL1wq3yiMUCiAV778zm0CNXlZCZu0h9EP21AVS0sIiMgfrUrCUijfMMUbR3U4tofapRpxIc3DSLGD39enHIy00L07YQDUbKTdaOUjipQ== X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: db243527-5305-4d5e-2581-08d7ccc1f6c9 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 11:29:34.4352 (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: LHK4TFgiY7v+uNHFsEN4ct7EP1ce//gksE+l6MnnmYvfYSXM78lWW6UyrHGFyM0hOP/pcW/cfr9d2ysvtOjC2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4062 Subject: [dpdk-dev] [PATCH v1] 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 ethdev_ops reta_update, reta_query rss_hash_update, rss_hash_conf_get Signed-off-by: Chandu Babu N --- drivers/net/axgbe/axgbe_dev.c | 5 +- drivers/net/axgbe/axgbe_ethdev.c | 146 +++++++++++++++++++++++++++++++ drivers/net/axgbe/axgbe_ethdev.h | 3 + 3 files changed, 152 insertions(+), 2 deletions(-) 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..f42bb7a0d 100644 --- a/drivers/net/axgbe/axgbe_ethdev.c +++ b/drivers/net/axgbe/axgbe_ethdev.c @@ -60,6 +60,18 @@ 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 +213,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 +466,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 || 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 || 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) { + PMD_DRV_LOG(ERR, "rss_conf value isn't valid\n"); + return -EINVAL; + } + + if (rss_conf->rss_key && + 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) + 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) { + PMD_DRV_LOG(ERR, "rss_conf value isn't valid\n"); + return -EINVAL; + } + + if (rss_conf->rss_key && + 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