Skip to content

Commit 8ce8427

Browse files
dimbezdavem330
authored andcommitted
net: atlantic: changes for multi-TC support
This patch contains the following changes: * access cfg via aq_nic_get_cfg() in aq_nic_start() and aq_nic_map_skb(); * call aq_nic_get_dev() just once in aq_nic_map_skb(); * move ring allocation/deallocation out of aq_vec_alloc()/aq_vec_free(); * add the missing aq_nic_deinit() in atl_resume_common(); * rename 'tcs' field to 'tcs_max' in aq_hw_caps_s to differentiate it from the 'tcs' field in aq_nic_cfg_s, which is used for the current number of TCs; * update _TC_MAX defines to the actual number of supported TCs; * move tx_tc_mode register defines slightly higher (just to keep the order of definitions); * separate variables for TX/RX buff_size in hw_atl*_hw_qos_set(); * use AQ_HW_*_TC instead of hardcoded magic numbers; * actually use the 'ret' value in aq_mdo_add_secy(); Signed-off-by: Dmitry Bezrukov <[email protected]> Co-developed-by: Mark Starovoytov <[email protected]> Signed-off-by: Mark Starovoytov <[email protected]> Signed-off-by: Igor Russkikh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 59b8d27 commit 8ce8427

File tree

12 files changed

+105
-72
lines changed

12 files changed

+105
-72
lines changed

drivers/net/ethernet/aquantia/atlantic/aq_hw.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct aq_hw_caps_s {
4646
u32 mac_regs_count;
4747
u32 hw_alive_check_addr;
4848
u8 msix_irqs;
49-
u8 tcs;
49+
u8 tcs_max;
5050
u8 rxd_alignment;
5151
u8 rxd_size;
5252
u8 txd_alignment;
@@ -120,6 +120,8 @@ struct aq_stats_s {
120120

121121
#define AQ_HW_MULTICAST_ADDRESS_MAX 32U
122122

123+
#define AQ_HW_PTP_TC 2U
124+
123125
#define AQ_HW_LED_BLINK 0x2U
124126
#define AQ_HW_LED_DEFAULT 0x0U
125127

drivers/net/ethernet/aquantia/atlantic/aq_macsec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static int aq_mdo_add_secy(struct macsec_context *ctx)
478478

479479
set_bit(txsc_idx, &cfg->txsc_idx_busy);
480480

481-
return 0;
481+
return ret;
482482
}
483483

484484
static int aq_mdo_upd_secy(struct macsec_context *ctx)

drivers/net/ethernet/aquantia/atlantic/aq_nic.c

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,15 @@ int aq_nic_init(struct aq_nic_s *self)
399399
err = aq_phy_init(self->aq_hw);
400400
}
401401

402-
for (i = 0U, aq_vec = self->aq_vec[0];
403-
self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])
402+
for (i = 0U; i < self->aq_vecs; i++) {
403+
aq_vec = self->aq_vec[i];
404+
err = aq_vec_ring_alloc(aq_vec, self, i,
405+
aq_nic_get_cfg(self));
406+
if (err)
407+
goto err_exit;
408+
404409
aq_vec_init(aq_vec, self->aq_hw_ops, self->aq_hw);
410+
}
405411

406412
err = aq_ptp_init(self, self->irqvecs - 1);
407413
if (err < 0)
@@ -424,9 +430,12 @@ int aq_nic_init(struct aq_nic_s *self)
424430
int aq_nic_start(struct aq_nic_s *self)
425431
{
426432
struct aq_vec_s *aq_vec = NULL;
433+
struct aq_nic_cfg_s *cfg;
427434
unsigned int i = 0U;
428435
int err = 0;
429436

437+
cfg = aq_nic_get_cfg(self);
438+
430439
err = self->aq_hw_ops->hw_multicast_list_set(self->aq_hw,
431440
self->mc_list.ar,
432441
self->mc_list.count);
@@ -464,7 +473,7 @@ int aq_nic_start(struct aq_nic_s *self)
464473
timer_setup(&self->service_timer, aq_nic_service_timer_cb, 0);
465474
aq_nic_service_timer_cb(&self->service_timer);
466475

467-
if (self->aq_nic_cfg.is_polling) {
476+
if (cfg->is_polling) {
468477
timer_setup(&self->polling_timer, aq_nic_polling_timer_cb, 0);
469478
mod_timer(&self->polling_timer, jiffies +
470479
AQ_CFG_POLLING_TIMER_INTERVAL);
@@ -482,16 +491,16 @@ int aq_nic_start(struct aq_nic_s *self)
482491
if (err < 0)
483492
goto err_exit;
484493

485-
if (self->aq_nic_cfg.link_irq_vec) {
494+
if (cfg->link_irq_vec) {
486495
int irqvec = pci_irq_vector(self->pdev,
487-
self->aq_nic_cfg.link_irq_vec);
496+
cfg->link_irq_vec);
488497
err = request_threaded_irq(irqvec, NULL,
489498
aq_linkstate_threaded_isr,
490499
IRQF_SHARED | IRQF_ONESHOT,
491500
self->ndev->name, self);
492501
if (err < 0)
493502
goto err_exit;
494-
self->msix_entry_mask |= (1 << self->aq_nic_cfg.link_irq_vec);
503+
self->msix_entry_mask |= (1 << cfg->link_irq_vec);
495504
}
496505

497506
err = self->aq_hw_ops->hw_irq_enable(self->aq_hw,
@@ -518,6 +527,8 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,
518527
struct aq_ring_s *ring)
519528
{
520529
unsigned int nr_frags = skb_shinfo(skb)->nr_frags;
530+
struct aq_nic_cfg_s *cfg = aq_nic_get_cfg(self);
531+
struct device *dev = aq_nic_get_dev(self);
521532
struct aq_ring_buff_s *first = NULL;
522533
u8 ipver = ip_hdr(skb)->version;
523534
struct aq_ring_buff_s *dx_buff;
@@ -559,7 +570,7 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,
559570
need_context_tag = true;
560571
}
561572

562-
if (self->aq_nic_cfg.is_vlan_tx_insert && skb_vlan_tag_present(skb)) {
573+
if (cfg->is_vlan_tx_insert && skb_vlan_tag_present(skb)) {
563574
dx_buff->vlan_tx_tag = skb_vlan_tag_get(skb);
564575
dx_buff->len_pkt = skb->len;
565576
dx_buff->is_vlan = 1U;
@@ -574,12 +585,12 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,
574585
}
575586

576587
dx_buff->len = skb_headlen(skb);
577-
dx_buff->pa = dma_map_single(aq_nic_get_dev(self),
588+
dx_buff->pa = dma_map_single(dev,
578589
skb->data,
579590
dx_buff->len,
580591
DMA_TO_DEVICE);
581592

582-
if (unlikely(dma_mapping_error(aq_nic_get_dev(self), dx_buff->pa))) {
593+
if (unlikely(dma_mapping_error(dev, dx_buff->pa))) {
583594
ret = 0;
584595
goto exit;
585596
}
@@ -611,13 +622,13 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,
611622
else
612623
buff_size = frag_len;
613624

614-
frag_pa = skb_frag_dma_map(aq_nic_get_dev(self),
625+
frag_pa = skb_frag_dma_map(dev,
615626
frag,
616627
buff_offset,
617628
buff_size,
618629
DMA_TO_DEVICE);
619630

620-
if (unlikely(dma_mapping_error(aq_nic_get_dev(self),
631+
if (unlikely(dma_mapping_error(dev,
621632
frag_pa)))
622633
goto mapping_error;
623634

@@ -651,12 +662,12 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,
651662
if (!(dx_buff->is_gso_tcp || dx_buff->is_gso_udp) &&
652663
!dx_buff->is_vlan && dx_buff->pa) {
653664
if (unlikely(dx_buff->is_sop)) {
654-
dma_unmap_single(aq_nic_get_dev(self),
665+
dma_unmap_single(dev,
655666
dx_buff->pa,
656667
dx_buff->len,
657668
DMA_TO_DEVICE);
658669
} else {
659-
dma_unmap_page(aq_nic_get_dev(self),
670+
dma_unmap_page(dev,
660671
dx_buff->pa,
661672
dx_buff->len,
662673
DMA_TO_DEVICE);
@@ -1145,9 +1156,11 @@ void aq_nic_deinit(struct aq_nic_s *self, bool link_down)
11451156
if (!self)
11461157
goto err_exit;
11471158

1148-
for (i = 0U, aq_vec = self->aq_vec[0];
1149-
self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i])
1159+
for (i = 0U; i < self->aq_vecs; i++) {
1160+
aq_vec = self->aq_vec[i];
11501161
aq_vec_deinit(aq_vec);
1162+
aq_vec_ring_free(aq_vec);
1163+
}
11511164

11521165
aq_ptp_unregister(self);
11531166
aq_ptp_ring_deinit(self);

drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,9 @@ static int atl_resume_common(struct device *dev, bool deep)
431431
netif_tx_start_all_queues(nic->ndev);
432432

433433
err_exit:
434+
if (ret < 0)
435+
aq_nic_deinit(nic, true);
436+
434437
rtnl_unlock();
435438

436439
return ret;

drivers/net/ethernet/aquantia/atlantic/aq_vec.c

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,11 @@ static int aq_vec_poll(struct napi_struct *napi, int budget)
103103
struct aq_vec_s *aq_vec_alloc(struct aq_nic_s *aq_nic, unsigned int idx,
104104
struct aq_nic_cfg_s *aq_nic_cfg)
105105
{
106-
struct aq_ring_s *ring = NULL;
107106
struct aq_vec_s *self = NULL;
108-
unsigned int i = 0U;
109-
int err = 0;
110107

111108
self = kzalloc(sizeof(*self), GFP_KERNEL);
112-
if (!self) {
113-
err = -ENOMEM;
109+
if (!self)
114110
goto err_exit;
115-
}
116111

117112
self->aq_nic = aq_nic;
118113
self->aq_ring_param.vec_idx = idx;
@@ -128,10 +123,19 @@ struct aq_vec_s *aq_vec_alloc(struct aq_nic_s *aq_nic, unsigned int idx,
128123
netif_napi_add(aq_nic_get_ndev(aq_nic), &self->napi,
129124
aq_vec_poll, AQ_CFG_NAPI_WEIGHT);
130125

126+
err_exit:
127+
return self;
128+
}
129+
130+
int aq_vec_ring_alloc(struct aq_vec_s *self, struct aq_nic_s *aq_nic,
131+
unsigned int idx, struct aq_nic_cfg_s *aq_nic_cfg)
132+
{
133+
struct aq_ring_s *ring = NULL;
134+
unsigned int i = 0U;
135+
int err = 0;
136+
131137
for (i = 0; i < aq_nic_cfg->tcs; ++i) {
132-
unsigned int idx_ring = AQ_NIC_TCVEC2RING(self->nic,
133-
self->tx_rings,
134-
self->aq_ring_param.vec_idx);
138+
unsigned int idx_ring = AQ_NIC_TCVEC2RING(aq_nic, i, idx);
135139

136140
ring = aq_ring_tx_alloc(&self->ring[i][AQ_VEC_TX_ID], aq_nic,
137141
idx_ring, aq_nic_cfg);
@@ -156,11 +160,11 @@ struct aq_vec_s *aq_vec_alloc(struct aq_nic_s *aq_nic, unsigned int idx,
156160

157161
err_exit:
158162
if (err < 0) {
159-
aq_vec_free(self);
163+
aq_vec_ring_free(self);
160164
self = NULL;
161165
}
162166

163-
return self;
167+
return err;
164168
}
165169

166170
int aq_vec_init(struct aq_vec_s *self, const struct aq_hw_ops *aq_hw_ops,
@@ -269,6 +273,18 @@ err_exit:;
269273
}
270274

271275
void aq_vec_free(struct aq_vec_s *self)
276+
{
277+
if (!self)
278+
goto err_exit;
279+
280+
netif_napi_del(&self->napi);
281+
282+
kfree(self);
283+
284+
err_exit:;
285+
}
286+
287+
void aq_vec_ring_free(struct aq_vec_s *self)
272288
{
273289
struct aq_ring_s *ring = NULL;
274290
unsigned int i = 0U;
@@ -279,13 +295,12 @@ void aq_vec_free(struct aq_vec_s *self)
279295
for (i = 0U, ring = self->ring[0];
280296
self->tx_rings > i; ++i, ring = self->ring[i]) {
281297
aq_ring_free(&ring[AQ_VEC_TX_ID]);
282-
aq_ring_free(&ring[AQ_VEC_RX_ID]);
298+
if (i < self->rx_rings)
299+
aq_ring_free(&ring[AQ_VEC_RX_ID]);
283300
}
284301

285-
netif_napi_del(&self->napi);
286-
287-
kfree(self);
288-
302+
self->tx_rings = 0;
303+
self->rx_rings = 0;
289304
err_exit:;
290305
}
291306

drivers/net/ethernet/aquantia/atlantic/aq_vec.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ irqreturn_t aq_vec_isr(int irq, void *private);
2525
irqreturn_t aq_vec_isr_legacy(int irq, void *private);
2626
struct aq_vec_s *aq_vec_alloc(struct aq_nic_s *aq_nic, unsigned int idx,
2727
struct aq_nic_cfg_s *aq_nic_cfg);
28+
int aq_vec_ring_alloc(struct aq_vec_s *self, struct aq_nic_s *aq_nic,
29+
unsigned int idx, struct aq_nic_cfg_s *aq_nic_cfg);
2830
int aq_vec_init(struct aq_vec_s *self, const struct aq_hw_ops *aq_hw_ops,
2931
struct aq_hw_s *aq_hw);
3032
void aq_vec_deinit(struct aq_vec_s *self);
3133
void aq_vec_free(struct aq_vec_s *self);
34+
void aq_vec_ring_free(struct aq_vec_s *self);
3235
int aq_vec_start(struct aq_vec_s *self);
3336
void aq_vec_stop(struct aq_vec_s *self);
3437
cpumask_t *aq_vec_get_affinity_mask(struct aq_vec_s *self);

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
.msix_irqs = 4U, \
2222
.irq_mask = ~0U, \
2323
.vecs = HW_ATL_A0_RSS_MAX, \
24-
.tcs = HW_ATL_A0_TC_MAX, \
24+
.tcs_max = HW_ATL_A0_TC_MAX, \
2525
.rxd_alignment = 1U, \
2626
.rxd_size = HW_ATL_A0_RXD_SIZE, \
2727
.rxds_max = HW_ATL_A0_MAX_RXD, \

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
.msix_irqs = 8U, \
2424
.irq_mask = ~0U, \
2525
.vecs = HW_ATL_B0_RSS_MAX, \
26-
.tcs = HW_ATL_B0_TC_MAX, \
26+
.tcs_max = HW_ATL_B0_TC_MAX, \
2727
.rxd_alignment = 1U, \
2828
.rxd_size = HW_ATL_B0_RXD_SIZE, \
2929
.rxds_max = HW_ATL_B0_MAX_RXD, \
@@ -116,8 +116,9 @@ static int hw_atl_b0_set_fc(struct aq_hw_s *self, u32 fc, u32 tc)
116116

117117
static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)
118118
{
119+
u32 tx_buff_size = HW_ATL_B0_TXBUF_MAX;
120+
u32 rx_buff_size = HW_ATL_B0_RXBUF_MAX;
119121
unsigned int i_priority = 0U;
120-
u32 buff_size = 0U;
121122
u32 tc = 0U;
122123

123124
/* TPS Descriptor rate init */
@@ -131,55 +132,48 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)
131132
hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set(self, 0U);
132133
hw_atl_tps_tx_pkt_shed_data_arb_mode_set(self, 0U);
133134

134-
tc = 0;
135-
136135
/* TX Packet Scheduler Data TC0 */
137136
hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set(self, 0xFFF, tc);
138137
hw_atl_tps_tx_pkt_shed_tc_data_weight_set(self, 0x64, tc);
139138
hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set(self, 0x50, tc);
140139
hw_atl_tps_tx_pkt_shed_desc_tc_weight_set(self, 0x1E, tc);
141140

142141
/* Tx buf size TC0 */
143-
buff_size = HW_ATL_B0_TXBUF_MAX - HW_ATL_B0_PTP_TXBUF_SIZE;
142+
tx_buff_size -= HW_ATL_B0_PTP_TXBUF_SIZE;
144143

145-
hw_atl_tpb_tx_pkt_buff_size_per_tc_set(self, buff_size, tc);
144+
hw_atl_tpb_tx_pkt_buff_size_per_tc_set(self, tx_buff_size, tc);
146145
hw_atl_tpb_tx_buff_hi_threshold_per_tc_set(self,
147-
(buff_size *
146+
(tx_buff_size *
148147
(1024 / 32U) * 66U) /
149148
100U, tc);
150149
hw_atl_tpb_tx_buff_lo_threshold_per_tc_set(self,
151-
(buff_size *
150+
(tx_buff_size *
152151
(1024 / 32U) * 50U) /
153152
100U, tc);
154153
/* Init TC2 for PTP_TX */
155-
tc = 2;
156-
157154
hw_atl_tpb_tx_pkt_buff_size_per_tc_set(self, HW_ATL_B0_PTP_TXBUF_SIZE,
158-
tc);
155+
AQ_HW_PTP_TC);
159156

160157
/* QoS Rx buf size per TC */
161-
tc = 0;
162-
buff_size = HW_ATL_B0_RXBUF_MAX - HW_ATL_B0_PTP_RXBUF_SIZE;
158+
rx_buff_size -= HW_ATL_B0_PTP_RXBUF_SIZE;
163159

164-
hw_atl_rpb_rx_pkt_buff_size_per_tc_set(self, buff_size, tc);
160+
hw_atl_rpb_rx_pkt_buff_size_per_tc_set(self, rx_buff_size, tc);
165161
hw_atl_rpb_rx_buff_hi_threshold_per_tc_set(self,
166-
(buff_size *
162+
(rx_buff_size *
167163
(1024U / 32U) * 66U) /
168164
100U, tc);
169165
hw_atl_rpb_rx_buff_lo_threshold_per_tc_set(self,
170-
(buff_size *
166+
(rx_buff_size *
171167
(1024U / 32U) * 50U) /
172168
100U, tc);
173169

174170
hw_atl_b0_set_fc(self, self->aq_nic_cfg->fc.req, tc);
175171

176172
/* Init TC2 for PTP_RX */
177-
tc = 2;
178-
179173
hw_atl_rpb_rx_pkt_buff_size_per_tc_set(self, HW_ATL_B0_PTP_RXBUF_SIZE,
180-
tc);
174+
AQ_HW_PTP_TC);
181175
/* No flow control for PTP */
182-
hw_atl_rpb_rx_xoff_en_per_tc_set(self, 0U, tc);
176+
hw_atl_rpb_rx_xoff_en_per_tc_set(self, 0U, AQ_HW_PTP_TC);
183177

184178
/* QoS 802.1p priority -> TC mapping */
185179
for (i_priority = 8U; i_priority--;)

drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
#define HW_ATL_B0_RSS_HASHKEY_BITS 320U
7676

7777
#define HW_ATL_B0_TCRSS_4_8 1
78-
#define HW_ATL_B0_TC_MAX 1U
78+
#define HW_ATL_B0_TC_MAX 8U
7979
#define HW_ATL_B0_RSS_MAX 8U
8080

8181
#define HW_ATL_B0_LRO_RXD_MAX 16U

0 commit comments

Comments
 (0)