From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from na01-by2-obe.outbound.protection.outlook.com (mail-eopbgr700082.outbound.protection.outlook.com [40.107.70.82]) by dpdk.org (Postfix) with ESMTP id 2BC8F568B for ; Mon, 13 Jun 2016 15:57:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/SSFU648vtZVAOwjQXgPAFKPdDkCJCZf6YuvldXGsIk=; b=a6NpDUa+qZha42b1UhgeucBAlrya0z6mjRQ7J7wgilPIllsoXEbSboaDJQIPyaI0DAPoV7bAVw+ynqqYoCYPnh8k9aFsvc2rtoAEiQ9mkYQCClVC/X8PbYtEsp/F1bEiAzuIBJx4r7VPqUQ2Sq7lKV9lmFomKp+6a/KsRmmDkHs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain.localdomain (171.48.21.3) by BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) with Microsoft SMTP Server (TLS) id 15.1.517.8; Mon, 13 Jun 2016 13:57:41 +0000 From: Jerin Jacob To: CC: , , , Jerin Jacob , Maciej Czekaj , Kamil Rytarowski , Zyta Szpak , Slawomir Rosek , Radoslaw Biernacki Date: Mon, 13 Jun 2016 19:25:39 +0530 Message-ID: <1465826143-22159-16-git-send-email-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> References: <1465317632-11471-2-git-send-email-jerin.jacob@caviumnetworks.com> <1465826143-22159-1-git-send-email-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.48.21.3] X-ClientProxiedBy: BM1PR01CA0031.INDPRD01.PROD.OUTLOOK.COM (10.163.198.166) To BN3PR0701MB1717.namprd07.prod.outlook.com (10.163.39.16) X-MS-Office365-Filtering-Correlation-Id: 6a6615bb-ba4b-4a4a-4fb8-08d39392b23a X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 2:OE3rmHTjLWJU4nKZvcSb0z8IYSE6aiZf1LoOQlnd9rxmp+JrHQxAfa9i5t3crfAI00jpULWiC8cGsyN76naEylWqHCChXhZN+vzajJqbXZYCzReS42EVMh0QKRk9rSsSAR8Yzvanx6EltymAE8H1MElXasYNM+ZwQvKMvvDfr0VQwQuYao5fayRrmu0Jfc9P; 3:BUTZ7S1H4FFKAyLCcwjUQXMEdoBYBhC6429FaTUPS+OHGrcmdCZEp0ySRgeaPOwKnLuCPKnbYpqxRELKNR0tMKn90Y4G172/62GsdNplmOmX98zHZMsN0VRvBNsnSK0Z; 25:cua8T9nydqax7RENppC8Ja4PJMewj84a+Z8ymdioDn5hoMmFQKVlv74FTpIOGvoErTtiiQ8qznP65xvOU2i8wNdOswmvVb5tESpU4DXaANshaIg37YENNOeT9Lig0pXx5xhEiZP3xAcfV1dLuYtAwNVdcgyXgiYsZ+uxZ2e9RmJsGXoDFS+ysptvjU77UIhc6b/zIOaJXe+nma+O9flSRsvQqMe/4pF61xTc1KcwcjFF1vSlIfk1HSxUXFXvx3wkRr67q4wqDwq/kz8aMIbQveemeUJnm+X7CKLXOKaxk6JM0dLQIRg7BIUOkePzzw/WmZ+xntNFoxFHoNfyEcNR2hP9INDs9uRaZ2l0cLEsneX6F2dEQJvTYBdXRLWQ0jg525F06zfddUQ3dSF94EJOTuhrZc2af7mq7lzZJ0SZcss= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 20:q62Wnc9yjuXfeiQk4ZER+QijEuc0OYx4lp+sFuBH/HZrRTrgHNIFLS2J+Vs9foYu73DtYq09geGIG1dqJP7K2r7IMXPRNwj7JH65c1jhL5FjUZ0wNWRrLvGioBlKGxqBsBh4ruSYhMg7ZDpOJUgW6o9Be9yH6gn/XMim0HECMxURwAFBwClsi6/OgKMayWxSEO+vYUnjoCTXyrOJtwjeTIFe4/8Up/46kDT97I9aGT9weSpDHXFsxzDc+p8vRw00YpSrRg8yjnvlc6/bFz3vTZeRq3FkBShKkgCvYdWpRDK2P92fTnAHfMhQJARN0R1ci3xYwlyQKcrcquNnK9u8UKYwiQkwBvvpY6JnQT8Dl0Sx6zedG5PnEDxSDG+omvR/ctMmsPZKEEy3Voad3i1ePm3czRa8LcGe1WEAQZOb5zd+/9sWaMh9owcGpJWHlQlJpSzyqoAOaiLOu/Z/xzBde06FtNu/YyUUV3K2tOixzgX1y7g2I3cYIAqAUa7rZrWRTrJl8HT6zo4QItA0DXKeqrpf9YjR7N3vDGUaW3wcvq1lnEcWxMxTNRFzppk0M/NUhith7SGYZjzKoF2gsmgXs6I19ZMjLbEO0+togHNNmKg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046); SRVR:BN3PR0701MB1717; BCL:0; PCL:0; RULEID:; SRVR:BN3PR0701MB1717; X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 4:LWp3YPpxX2HrfnsxKZJX3kLNmWTV0vaZR7gLeAL7BSjoNGRu8h9H+OyeWAeYPhJixMboHZ33ET1JyjvEiLYcBYgO85i1QPj7iKjfBw6oHrhFoxmtnvc+HvTzr3xKvjvsgo7rMfh8NCWnstLIdEwqwtCYAQ4mBx1OG6smfo6uHeg2VXM/BsUwyRQSOZTBGowikMTW8IyOS5aRMqgbVQKazwNdRSTgC13PHF7f/O0DDlcfMpijoCT6SsFBensGFPQH7zFqlkiGZO3g7zyAlT8ym8v3uszfylrYpabQ0k6Ob2scQQLfpqZ81dU4DrP8Zn36pej5VumgMyGukQ+7kdLquFV6bm2E7hK0yFpW7ngRNmyuT3sIqEI8SfZndXOiX9vu X-Forefront-PRVS: 0972DEC1D9 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(189002)(199003)(50466002)(48376002)(101416001)(42186005)(50986999)(92566002)(76176999)(105586002)(106356001)(33646002)(2351001)(5004730100002)(47776003)(66066001)(36756003)(586003)(3846002)(6116002)(19580405001)(19580395003)(77096005)(8676002)(2906002)(81156014)(81166006)(4326007)(189998001)(97736004)(2950100001)(110136002)(5008740100001)(229853001)(5003940100001)(50226002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR0701MB1717; H:localhost.localdomain.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR0701MB1717; 23:QdMu3+DPav93noj4QdWJJoWobMWRJwNh7xaUZmC?= =?us-ascii?Q?mh5ZNzVVPg8Irc6mZWOz3hoqxdxcsu00PXui+uy0tIzZGY38lXQMll0tcXAk?= =?us-ascii?Q?8c58B/ScBJO2j1UenDDPEki9LH05yNxXdj61u5zgkZi6wMZ6Bn0NB4unvD4k?= =?us-ascii?Q?/U9JLAvt8KGROKHj7KVNkKWyDaMb3XF7i6iUnVWvDpHriMEY+ll18Hv4pXS/?= =?us-ascii?Q?wEF8Rq2wttL76O3A48Aals2o8QCRNTXnW7FpH93vfhDZXNxfikI2jobOE4Hm?= =?us-ascii?Q?aKdumo6WaTzy/sUqqUqCSgSAipqFLVgpOYHIX7luBno16uiavvKkk1ZY6mDF?= =?us-ascii?Q?UBmPnBtYCJ0sWrCXrI6wuzI6VfHQtbIq4FSQYA6iQ9/Sj4s2bERFZi8bn7wm?= =?us-ascii?Q?edDepDC57o/yw98IrS89D3Jv5kSU3wt3Zu2pn0D8Wp3/CNP06XdXA2rRc0Gt?= =?us-ascii?Q?mUwuLBg1KF7TjbfYAlSFaZ+1ChUtFcV68AIsNbufwRJ5OLonty6L2I74IxVW?= =?us-ascii?Q?pCWcB7ubTg0G6HIf2munylO5ALkgob6gkmntBxMFwga8Knj81CH+rFTfgerB?= =?us-ascii?Q?UTtDcq0H0Yjjpps03szhNCQxgXb6XQYVq8iIwP6y4W59SG9v87uE0dVuJ+VV?= =?us-ascii?Q?mmrasImxV50xhUQSskdlhF/ZEGiwKRaMvHu1i/EvqDwQh5iOtZF4ifnUD7Bk?= =?us-ascii?Q?j0z4YfudCrABIU09Ti2nh/zue8QnKny7Jm/0TqbLJDJbYrsgnfeVXUWpHPm7?= =?us-ascii?Q?OhuiMJDKSsJXF66vy468fAe0BILFXQ6riF8jww1iD3HJCyytUJi+BO2Q+qwq?= =?us-ascii?Q?soMfT+NLbli7Cl800+D/fHEtmS2ass+G4Z1id33Ku7PXlDKduRd/bKoVSpkV?= =?us-ascii?Q?XxYRBTd738hGG9KMK9lLLN9R/6GQbQV95nlrM6QKh+5xjNu1llNOwzgSs0Z2?= =?us-ascii?Q?zVShrxiwlx4SUypzHhIMG0m/NjFoph0yNgZZU7mEWdRIVwNkNuyPDC4gmdrb?= =?us-ascii?Q?GNqDXzoe0LpcEBlcS343z2iIquLBoLimQYR2WyUWRwOEdski19rmDPt2djHr?= =?us-ascii?Q?gUuv0RYfuPERgluHFkFjP5YJIzzgt?= X-Microsoft-Exchange-Diagnostics: 1; BN3PR0701MB1717; 6:M9iHuXrnmJYq/BnBQBFCjNgsS4qlDZO9nJfmmU4iQKezO6AcDuidSt5eYlj2TQYiueVaO71dZLXL5w51g/iC91zXKRI/CkT8KBMYxQmHXYYHG7QFGyZITl25cRkD57kOG6g3vCbrCgZy4BuS/lZrUqs8HiA42ecCJjohzYOMYQ+1WrAgRWRdIQM1Wvew8xzHCuj2lyLN2NSosLUoZKrEAQ9MO1aVQI6hUXUPZl62aZF74Llpd1UMURfklP945AdI/NXatHZjho8sM1+ulIsp1Qi/HxxA7qCt21jxm3NBh7E=; 5:kJGI9jxbG/9u4BYcJMIn+7UQqefpyG9+Yp9OOIfVh7RWnaL4hvepglrJ9b8Gskr2KIdvpYqcnYDxW/MJuCzjkfmQGJKKjaHfOFAWMTxmQt3Ma4XeS2J5znhewlH/nUSIPHYJeXjuOqzW6XORo8mCMQ==; 24:BBrpOc5BXY03Ji18fUxY4m/71zdegwyCI3vRFjX0HnS3rFoMSVKkQihBVDHy/m+EYbRbr2TIs9ViDTxkISn/dFSPyvI3ZgWCVtuDGXLORqo=; 7:vLzSIods2ol6b4uKNYnq5cySjdR8iZyoxy94TKe+9nNJmala6MhD/2vSkR2VsixxYeDJA4yRcwhY1Q9208X0XshY4C/8yhApxIqaWpUM5Vx4UfVeFis3YGKvKxAQLRrb4NQ9lES+0cdxWEYKlXZXVdHRd6SaWd5gw93kc83f1St9C8Wi5IlMNtn20iN7xyuQbk4wzdYLgmfXqGQkTVgkaJ+gLmvOYfUlEfFC4snOQxg= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jun 2016 13:57:41.5975 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0701MB1717 Subject: [dpdk-dev] [PATCH v4 15/19] net/thunderx: add rx queue start and stop support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jun 2016 13:57:48 -0000 Signed-off-by: Jerin Jacob Signed-off-by: Maciej Czekaj Signed-off-by: Kamil Rytarowski Signed-off-by: Zyta Szpak Signed-off-by: Slawomir Rosek Signed-off-by: Radoslaw Biernacki --- drivers/net/thunderx/nicvf_ethdev.c | 167 ++++++++++++++++++++++++++++++++++++ drivers/net/thunderx/nicvf_rxtx.c | 18 ++++ drivers/net/thunderx/nicvf_rxtx.h | 1 + 3 files changed, 186 insertions(+) diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c index 8b8d9d9..7a58cb3 100644 --- a/drivers/net/thunderx/nicvf_ethdev.c +++ b/drivers/net/thunderx/nicvf_ethdev.c @@ -562,6 +562,54 @@ nicvf_tx_queue_reset(struct nicvf_txq *txq) txq->xmit_bufs = 0; } + +static inline int +nicvf_configure_cpi(struct rte_eth_dev *dev) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + uint16_t qidx, qcnt; + int ret; + + /* Count started rx queues */ + for (qidx = qcnt = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) + if (dev->data->rx_queue_state[qidx] == + RTE_ETH_QUEUE_STATE_STARTED) + qcnt++; + + nic->cpi_alg = CPI_ALG_NONE; + ret = nicvf_mbox_config_cpi(nic, qcnt); + if (ret) + PMD_INIT_LOG(ERR, "Failed to configure CPI %d", ret); + + return ret; +} + +static int +nicvf_configure_rss_reta(struct rte_eth_dev *dev) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + unsigned int idx, qmap_size; + uint8_t qmap[RTE_MAX_QUEUES_PER_PORT]; + uint8_t default_reta[NIC_MAX_RSS_IDR_TBL_SIZE]; + + if (nic->cpi_alg != CPI_ALG_NONE) + return -EINVAL; + + /* Prepare queue map */ + for (idx = 0, qmap_size = 0; idx < dev->data->nb_rx_queues; idx++) { + if (dev->data->rx_queue_state[idx] == + RTE_ETH_QUEUE_STATE_STARTED) + qmap[qmap_size++] = idx; + } + + /* Update default RSS RETA */ + for (idx = 0; idx < NIC_MAX_RSS_IDR_TBL_SIZE; idx++) + default_reta[idx] = qmap[idx % qmap_size]; + + return nicvf_rss_reta_update(nic, default_reta, + NIC_MAX_RSS_IDR_TBL_SIZE); +} + static void nicvf_dev_tx_queue_release(void *sq) { @@ -687,6 +735,33 @@ nicvf_dev_tx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, return 0; } +static inline void +nicvf_rx_queue_release_mbufs(struct nicvf_rxq *rxq) +{ + uint32_t rxq_cnt; + uint32_t nb_pkts, released_pkts = 0; + uint32_t refill_cnt = 0; + struct rte_eth_dev *dev = rxq->nic->eth_dev; + struct rte_mbuf *rx_pkts[NICVF_MAX_RX_FREE_THRESH]; + + if (dev->rx_pkt_burst == NULL) + return; + + while ((rxq_cnt = nicvf_dev_rx_queue_count(dev, rxq->queue_id))) { + nb_pkts = dev->rx_pkt_burst(rxq, rx_pkts, + NICVF_MAX_RX_FREE_THRESH); + PMD_DRV_LOG(INFO, "nb_pkts=%d rxq_cnt=%d", nb_pkts, rxq_cnt); + while (nb_pkts) { + rte_pktmbuf_free_seg(rx_pkts[--nb_pkts]); + released_pkts++; + } + } + + refill_cnt += nicvf_dev_rbdr_refill(dev, rxq->queue_id); + PMD_DRV_LOG(INFO, "free_cnt=%d refill_cnt=%d", + released_pkts, refill_cnt); +} + static void nicvf_rx_queue_reset(struct nicvf_rxq *rxq) { @@ -695,6 +770,69 @@ nicvf_rx_queue_reset(struct nicvf_rxq *rxq) rxq->recv_buffers = 0; } +static inline int +nicvf_start_rx_queue(struct rte_eth_dev *dev, uint16_t qidx) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + struct nicvf_rxq *rxq; + int ret; + + if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STARTED) + return 0; + + /* Update rbdr pointer to all rxq */ + rxq = dev->data->rx_queues[qidx]; + rxq->shared_rbdr = nic->rbdr; + + ret = nicvf_qset_rq_config(nic, qidx, rxq); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to configure rq %d %d", qidx, ret); + goto config_rq_error; + } + ret = nicvf_qset_cq_config(nic, qidx, rxq); + if (ret) { + PMD_INIT_LOG(ERR, "Failed to configure cq %d %d", qidx, ret); + goto config_cq_error; + } + + dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STARTED; + return 0; + +config_cq_error: + nicvf_qset_cq_reclaim(nic, qidx); +config_rq_error: + nicvf_qset_rq_reclaim(nic, qidx); + return ret; +} + +static inline int +nicvf_stop_rx_queue(struct rte_eth_dev *dev, uint16_t qidx) +{ + struct nicvf *nic = nicvf_pmd_priv(dev); + struct nicvf_rxq *rxq; + int ret, other_error; + + if (dev->data->rx_queue_state[qidx] == RTE_ETH_QUEUE_STATE_STOPPED) + return 0; + + ret = nicvf_qset_rq_reclaim(nic, qidx); + if (ret) + PMD_INIT_LOG(ERR, "Failed to reclaim rq %d %d", qidx, ret); + + other_error = ret; + rxq = dev->data->rx_queues[qidx]; + nicvf_rx_queue_release_mbufs(rxq); + nicvf_rx_queue_reset(rxq); + + ret = nicvf_qset_cq_reclaim(nic, qidx); + if (ret) + PMD_INIT_LOG(ERR, "Failed to reclaim cq %d %d", qidx, ret); + + other_error |= ret; + dev->data->rx_queue_state[qidx] = RTE_ETH_QUEUE_STATE_STOPPED; + return other_error; +} + static void nicvf_dev_rx_queue_release(void *rx_queue) { @@ -707,6 +845,33 @@ nicvf_dev_rx_queue_release(void *rx_queue) } static int +nicvf_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t qidx) +{ + int ret; + + ret = nicvf_start_rx_queue(dev, qidx); + if (ret) + return ret; + + ret = nicvf_configure_cpi(dev); + if (ret) + return ret; + + return nicvf_configure_rss_reta(dev); +} + +static int +nicvf_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t qidx) +{ + int ret; + + ret = nicvf_stop_rx_queue(dev, qidx); + ret |= nicvf_configure_cpi(dev); + ret |= nicvf_configure_rss_reta(dev); + return ret; +} + +static int nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx, uint16_t nb_desc, unsigned int socket_id, const struct rte_eth_rxconf *rx_conf, @@ -933,6 +1098,8 @@ static const struct eth_dev_ops nicvf_eth_dev_ops = { .reta_query = nicvf_dev_reta_query, .rss_hash_update = nicvf_dev_rss_hash_update, .rss_hash_conf_get = nicvf_dev_rss_hash_conf_get, + .rx_queue_start = nicvf_dev_rx_queue_start, + .rx_queue_stop = nicvf_dev_rx_queue_stop, .rx_queue_setup = nicvf_dev_rx_queue_setup, .rx_queue_release = nicvf_dev_rx_queue_release, .rx_queue_count = nicvf_dev_rx_queue_count, diff --git a/drivers/net/thunderx/nicvf_rxtx.c b/drivers/net/thunderx/nicvf_rxtx.c index 1c6d6a8..eb51a72 100644 --- a/drivers/net/thunderx/nicvf_rxtx.c +++ b/drivers/net/thunderx/nicvf_rxtx.c @@ -579,3 +579,21 @@ nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx) rxq = dev->data->rx_queues[queue_idx]; return nicvf_addr_read(rxq->cq_status) & NICVF_CQ_CQE_COUNT_MASK; } + +uint32_t +nicvf_dev_rbdr_refill(struct rte_eth_dev *dev, uint16_t queue_idx) +{ + struct nicvf_rxq *rxq; + uint32_t to_process; + uint32_t rx_free; + + rxq = dev->data->rx_queues[queue_idx]; + to_process = rxq->recv_buffers; + while (rxq->recv_buffers > 0) { + rx_free = RTE_MIN(rxq->recv_buffers, NICVF_MAX_RX_FREE_THRESH); + rxq->recv_buffers -= nicvf_fill_rbdr(rxq, rx_free); + } + + assert(rxq->recv_buffers == 0); + return to_process; +} diff --git a/drivers/net/thunderx/nicvf_rxtx.h b/drivers/net/thunderx/nicvf_rxtx.h index ded87f3..9dad8a5 100644 --- a/drivers/net/thunderx/nicvf_rxtx.h +++ b/drivers/net/thunderx/nicvf_rxtx.h @@ -85,6 +85,7 @@ fill_sq_desc_gather(union sq_entry_t *entry, struct rte_mbuf *pkt) #endif uint32_t nicvf_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t queue_idx); +uint32_t nicvf_dev_rbdr_refill(struct rte_eth_dev *dev, uint16_t queue_idx); uint16_t nicvf_recv_pkts(void *rxq, struct rte_mbuf **rx_pkts, uint16_t pkts); uint16_t nicvf_recv_pkts_multiseg(void *rx_queue, struct rte_mbuf **rx_pkts, -- 2.5.5