John Lo | 55bf5c9 | 2016-07-04 23:23:32 -0400 | [diff] [blame^] | 1 | From 3131adb7f4195771bf54b294b2ee496055c3e65d Mon Sep 17 00:00:00 2001 |
| 2 | From: Nelson Escobar <neescoba@cisco.com> |
| 3 | Date: Tue, 14 Jun 2016 11:54:01 -0700 |
| 4 | Subject: [PATCH 25/25] enic: fixup of Rx Scatter patch |
| 5 | |
| 6 | A version of the Rx Scatter patch was used by VPP before the |
| 7 | patch was accepted in dpdk.org. This patch contains the change |
| 8 | made to the patch before it was accepted. |
| 9 | |
| 10 | Composed of internal dpdk devel patches: |
| 11 | enic: fixup rq count usage in wake of rx scatter |
| 12 | enic: update checks since RX scatter uses 2 VIC RQs per app RQ. |
| 13 | enic: fix packet type and flags when doing scatter Rx |
| 14 | |
| 15 | fixes: ENIC scatter RX |
| 16 | |
| 17 | Signed-off-by: Nelson Escobar <neescoba@cisco.com> |
| 18 | --- |
| 19 | drivers/net/enic/enic.h | 12 ++++++++++-- |
| 20 | drivers/net/enic/enic_ethdev.c | 7 +++++-- |
| 21 | drivers/net/enic/enic_main.c | 19 +++++++++++-------- |
| 22 | drivers/net/enic/enic_res.c | 5 +++-- |
| 23 | drivers/net/enic/enic_rxtx.c | 7 +++++-- |
| 24 | 5 files changed, 34 insertions(+), 16 deletions(-) |
| 25 | |
| 26 | diff --git a/drivers/net/enic/enic.h b/drivers/net/enic/enic.h |
| 27 | index 8b0fa05..9cc9f0b 100644 |
| 28 | --- a/drivers/net/enic/enic.h |
| 29 | +++ b/drivers/net/enic/enic.h |
| 30 | @@ -55,8 +55,11 @@ |
| 31 | #define DRV_COPYRIGHT "Copyright 2008-2015 Cisco Systems, Inc" |
| 32 | |
| 33 | #define ENIC_WQ_MAX 8 |
| 34 | -#define ENIC_RQ_MAX 8 |
| 35 | -#define ENIC_CQ_MAX (ENIC_WQ_MAX + ENIC_RQ_MAX) |
| 36 | +/* With Rx scatter support, we use two RQs on VIC per RQ used by app. Both |
| 37 | + * RQs use the same CQ. |
| 38 | + */ |
| 39 | +#define ENIC_RQ_MAX 16 |
| 40 | +#define ENIC_CQ_MAX (ENIC_WQ_MAX + (ENIC_RQ_MAX / 2)) |
| 41 | #define ENIC_INTR_MAX (ENIC_CQ_MAX + 2) |
| 42 | |
| 43 | #define VLAN_ETH_HLEN 18 |
| 44 | @@ -163,6 +166,11 @@ static inline unsigned int enic_data_rq(__rte_unused struct enic *enic, unsigned |
| 45 | return rq * 2 + 1; |
| 46 | } |
| 47 | |
| 48 | +static inline unsigned int enic_vnic_rq_count(struct enic *enic) |
| 49 | +{ |
| 50 | + return (enic->rq_count * 2); |
| 51 | +} |
| 52 | + |
| 53 | static inline unsigned int enic_cq_rq(__rte_unused struct enic *enic, unsigned int rq) |
| 54 | { |
| 55 | /* Scatter rx uses two receive queues together with one |
| 56 | diff --git a/drivers/net/enic/enic_ethdev.c b/drivers/net/enic/enic_ethdev.c |
| 57 | index 697ff82..e5b84e1 100644 |
| 58 | --- a/drivers/net/enic/enic_ethdev.c |
| 59 | +++ b/drivers/net/enic/enic_ethdev.c |
| 60 | @@ -269,9 +269,12 @@ static int enicpmd_dev_rx_queue_setup(struct rte_eth_dev *eth_dev, |
| 61 | struct enic *enic = pmd_priv(eth_dev); |
| 62 | |
| 63 | ENICPMD_FUNC_TRACE(); |
| 64 | - if (queue_idx >= ENIC_RQ_MAX) { |
| 65 | + /* With Rx scatter support, two RQs are now used on VIC per RQ used |
| 66 | + * by the application. |
| 67 | + */ |
| 68 | + if (queue_idx * 2 >= ENIC_RQ_MAX) { |
| 69 | dev_err(enic, |
| 70 | - "Max number of RX queues exceeded. Max is %d\n", |
| 71 | + "Max number of RX queues exceeded. Max is %d. This PMD uses 2 RQs on VIC per RQ used by DPDK.\n", |
| 72 | ENIC_RQ_MAX); |
| 73 | return -EINVAL; |
| 74 | } |
| 75 | diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c |
| 76 | index 976c9da..ff94ee2 100644 |
| 77 | --- a/drivers/net/enic/enic_main.c |
| 78 | +++ b/drivers/net/enic/enic_main.c |
| 79 | @@ -133,7 +133,7 @@ static void enic_log_q_error(struct enic *enic) |
| 80 | error_status); |
| 81 | } |
| 82 | |
| 83 | - for (i = 0; i < enic->rq_count; i++) { |
| 84 | + for (i = 0; i < enic_vnic_rq_count(enic); i++) { |
| 85 | error_status = vnic_rq_error_status(&enic->rq[i]); |
| 86 | if (error_status) |
| 87 | dev_err(enic, "RQ[%d] error_status %d\n", i, |
| 88 | @@ -486,7 +486,7 @@ int enic_alloc_intr_resources(struct enic *enic) |
| 89 | |
| 90 | dev_info(enic, "vNIC resources used: "\ |
| 91 | "wq %d rq %d cq %d intr %d\n", |
| 92 | - enic->wq_count, enic->rq_count, |
| 93 | + enic->wq_count, enic_vnic_rq_count(enic), |
| 94 | enic->cq_count, enic->intr_count); |
| 95 | |
| 96 | err = vnic_intr_alloc(enic->vdev, &enic->intr, 0); |
| 97 | @@ -790,10 +790,12 @@ int enic_disable(struct enic *enic) |
| 98 | if (err) |
| 99 | return err; |
| 100 | } |
| 101 | - for (i = 0; i < enic->rq_count; i++) { |
| 102 | - err = vnic_rq_disable(&enic->rq[i]); |
| 103 | - if (err) |
| 104 | - return err; |
| 105 | + for (i = 0; i < enic_vnic_rq_count(enic); i++) { |
| 106 | + if (enic->rq[i].in_use) { |
| 107 | + err = vnic_rq_disable(&enic->rq[i]); |
| 108 | + if (err) |
| 109 | + return err; |
| 110 | + } |
| 111 | } |
| 112 | |
| 113 | vnic_dev_set_reset_flag(enic->vdev, 1); |
| 114 | @@ -802,8 +804,9 @@ int enic_disable(struct enic *enic) |
| 115 | for (i = 0; i < enic->wq_count; i++) |
| 116 | vnic_wq_clean(&enic->wq[i], enic_free_wq_buf); |
| 117 | |
| 118 | - for (i = 0; i < enic->rq_count; i++) |
| 119 | - vnic_rq_clean(&enic->rq[i], enic_free_rq_buf); |
| 120 | + for (i = 0; i < enic_vnic_rq_count(enic); i++) |
| 121 | + if (enic->rq[i].in_use) |
| 122 | + vnic_rq_clean(&enic->rq[i], enic_free_rq_buf); |
| 123 | for (i = 0; i < enic->cq_count; i++) |
| 124 | vnic_cq_clean(&enic->cq[i]); |
| 125 | vnic_intr_clean(&enic->intr); |
| 126 | diff --git a/drivers/net/enic/enic_res.c b/drivers/net/enic/enic_res.c |
| 127 | index ebe379d..42edd84 100644 |
| 128 | --- a/drivers/net/enic/enic_res.c |
| 129 | +++ b/drivers/net/enic/enic_res.c |
| 130 | @@ -196,8 +196,9 @@ void enic_free_vnic_resources(struct enic *enic) |
| 131 | |
| 132 | for (i = 0; i < enic->wq_count; i++) |
| 133 | vnic_wq_free(&enic->wq[i]); |
| 134 | - for (i = 0; i < enic->rq_count; i++) |
| 135 | - vnic_rq_free(&enic->rq[i]); |
| 136 | + for (i = 0; i < enic_vnic_rq_count(enic); i++) |
| 137 | + if (enic->rq[i].in_use) |
| 138 | + vnic_rq_free(&enic->rq[i]); |
| 139 | for (i = 0; i < enic->cq_count; i++) |
| 140 | vnic_cq_free(&enic->cq[i]); |
| 141 | vnic_intr_free(&enic->intr); |
| 142 | diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c |
| 143 | index 463b954..c68bbfb 100644 |
| 144 | --- a/drivers/net/enic/enic_rxtx.c |
| 145 | +++ b/drivers/net/enic/enic_rxtx.c |
| 146 | @@ -326,8 +326,7 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, |
| 147 | |
| 148 | /* Fill in the rest of the mbuf */ |
| 149 | seg_length = enic_cq_rx_desc_n_bytes(&cqd); |
| 150 | - rxmb->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd); |
| 151 | - enic_cq_rx_to_pkt_flags(&cqd, rxmb); |
| 152 | + |
| 153 | if (rq->is_sop) { |
| 154 | first_seg = rxmb; |
| 155 | first_seg->nb_segs = 1; |
| 156 | @@ -350,6 +349,10 @@ enic_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, |
| 157 | continue; |
| 158 | } |
| 159 | |
| 160 | + /* cq rx flags are only valid if eop bit is set */ |
| 161 | + first_seg->packet_type = enic_cq_rx_flags_to_pkt_type(&cqd); |
| 162 | + enic_cq_rx_to_pkt_flags(&cqd, first_seg); |
| 163 | + |
| 164 | if (unlikely(packet_error)) { |
| 165 | rte_pktmbuf_free(first_seg); |
| 166 | rte_atomic64_inc(&enic->soft_stats.rx_packet_errors); |
| 167 | -- |
| 168 | 2.7.0 |
| 169 | |