Skip to content

Commit 0a06069

Browse files
committed
Merge branch 'aquantia-fixes'
Igor Russkikh says: ==================== net: aquantia: Atlantic driver 12/2017 updates The patchset contains important hardware fix for machines with large MRRS and couple of improvement in stats and capabilities reporting patch v3: - Fixed patch #7 after Andrew's finding. NIC level stats actually have to be cleaned only on hw struct creation (and this is done in kzalloc). On each hwinit we only have to reset link state to make sure hw stats update will not increment nic stats during init. patch v2: - split into more detailed commits Comment from David on wrong defines case will be submitted separately later ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 35b99df + d4c242d commit 0a06069

File tree

12 files changed

+177
-106
lines changed

12 files changed

+177
-106
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#define AQ_CFG_PCI_FUNC_MSIX_IRQS 9U
5151
#define AQ_CFG_PCI_FUNC_PORTS 2U
5252

53-
#define AQ_CFG_SERVICE_TIMER_INTERVAL (2 * HZ)
53+
#define AQ_CFG_SERVICE_TIMER_INTERVAL (1 * HZ)
5454
#define AQ_CFG_POLLING_TIMER_INTERVAL ((unsigned int)(2 * HZ))
5555

5656
#define AQ_CFG_SKB_FRAGS_MAX 32U
@@ -80,6 +80,7 @@
8080
#define AQ_CFG_DRV_VERSION __stringify(NIC_MAJOR_DRIVER_VERSION)"."\
8181
__stringify(NIC_MINOR_DRIVER_VERSION)"."\
8282
__stringify(NIC_BUILD_DRIVER_VERSION)"."\
83-
__stringify(NIC_REVISION_DRIVER_VERSION)
83+
__stringify(NIC_REVISION_DRIVER_VERSION) \
84+
AQ_CFG_DRV_VERSION_SUFFIX
8485

8586
#endif /* AQ_CFG_H */

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = {
6666
"OutUCast",
6767
"OutMCast",
6868
"OutBCast",
69-
"InUCastOctects",
70-
"OutUCastOctects",
71-
"InMCastOctects",
72-
"OutMCastOctects",
73-
"InBCastOctects",
74-
"OutBCastOctects",
75-
"InOctects",
76-
"OutOctects",
69+
"InUCastOctets",
70+
"OutUCastOctets",
71+
"InMCastOctets",
72+
"OutMCastOctets",
73+
"InBCastOctets",
74+
"OutBCastOctets",
75+
"InOctets",
76+
"OutOctets",
7777
"InPacketsDma",
7878
"OutPacketsDma",
7979
"InOctetsDma",

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,28 @@ struct aq_hw_link_status_s {
4646
unsigned int mbps;
4747
};
4848

49+
struct aq_stats_s {
50+
u64 uprc;
51+
u64 mprc;
52+
u64 bprc;
53+
u64 erpt;
54+
u64 uptc;
55+
u64 mptc;
56+
u64 bptc;
57+
u64 erpr;
58+
u64 mbtc;
59+
u64 bbtc;
60+
u64 mbrc;
61+
u64 bbrc;
62+
u64 ubrc;
63+
u64 ubtc;
64+
u64 dpc;
65+
u64 dma_pkt_rc;
66+
u64 dma_pkt_tc;
67+
u64 dma_oct_rc;
68+
u64 dma_oct_tc;
69+
};
70+
4971
#define AQ_HW_IRQ_INVALID 0U
5072
#define AQ_HW_IRQ_LEGACY 1U
5173
#define AQ_HW_IRQ_MSI 2U
@@ -85,7 +107,9 @@ struct aq_hw_ops {
85107
void (*destroy)(struct aq_hw_s *self);
86108

87109
int (*get_hw_caps)(struct aq_hw_s *self,
88-
struct aq_hw_caps_s *aq_hw_caps);
110+
struct aq_hw_caps_s *aq_hw_caps,
111+
unsigned short device,
112+
unsigned short subsystem_device);
89113

90114
int (*hw_ring_tx_xmit)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
91115
unsigned int frags);
@@ -164,8 +188,7 @@ struct aq_hw_ops {
164188

165189
int (*hw_update_stats)(struct aq_hw_s *self);
166190

167-
int (*hw_get_hw_stats)(struct aq_hw_s *self, u64 *data,
168-
unsigned int *p_count);
191+
struct aq_stats_s *(*hw_get_hw_stats)(struct aq_hw_s *self);
169192

170193
int (*hw_get_fw_version)(struct aq_hw_s *self, u32 *fw_version);
171194

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

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ static unsigned int aq_itr_rx;
3737
module_param_named(aq_itr_rx, aq_itr_rx, uint, 0644);
3838
MODULE_PARM_DESC(aq_itr_rx, "RX interrupt throttle rate");
3939

40+
static void aq_nic_update_ndev_stats(struct aq_nic_s *self);
41+
4042
static void aq_nic_rss_init(struct aq_nic_s *self, unsigned int num_rss_queues)
4143
{
4244
struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg;
@@ -166,11 +168,8 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)
166168
static void aq_nic_service_timer_cb(struct timer_list *t)
167169
{
168170
struct aq_nic_s *self = from_timer(self, t, service_timer);
169-
struct net_device *ndev = aq_nic_get_ndev(self);
171+
int ctimer = AQ_CFG_SERVICE_TIMER_INTERVAL;
170172
int err = 0;
171-
unsigned int i = 0U;
172-
struct aq_ring_stats_rx_s stats_rx;
173-
struct aq_ring_stats_tx_s stats_tx;
174173

175174
if (aq_utils_obj_test(&self->header.flags, AQ_NIC_FLAGS_IS_NOT_READY))
176175
goto err_exit;
@@ -182,23 +181,14 @@ static void aq_nic_service_timer_cb(struct timer_list *t)
182181
if (self->aq_hw_ops.hw_update_stats)
183182
self->aq_hw_ops.hw_update_stats(self->aq_hw);
184183

185-
memset(&stats_rx, 0U, sizeof(struct aq_ring_stats_rx_s));
186-
memset(&stats_tx, 0U, sizeof(struct aq_ring_stats_tx_s));
187-
for (i = AQ_DIMOF(self->aq_vec); i--;) {
188-
if (self->aq_vec[i])
189-
aq_vec_add_stats(self->aq_vec[i], &stats_rx, &stats_tx);
190-
}
184+
aq_nic_update_ndev_stats(self);
191185

192-
ndev->stats.rx_packets = stats_rx.packets;
193-
ndev->stats.rx_bytes = stats_rx.bytes;
194-
ndev->stats.rx_errors = stats_rx.errors;
195-
ndev->stats.tx_packets = stats_tx.packets;
196-
ndev->stats.tx_bytes = stats_tx.bytes;
197-
ndev->stats.tx_errors = stats_tx.errors;
186+
/* If no link - use faster timer rate to detect link up asap */
187+
if (!netif_carrier_ok(self->ndev))
188+
ctimer = max(ctimer / 2, 1);
198189

199190
err_exit:
200-
mod_timer(&self->service_timer,
201-
jiffies + AQ_CFG_SERVICE_TIMER_INTERVAL);
191+
mod_timer(&self->service_timer, jiffies + ctimer);
202192
}
203193

204194
static void aq_nic_polling_timer_cb(struct timer_list *t)
@@ -222,7 +212,7 @@ static struct net_device *aq_nic_ndev_alloc(void)
222212

223213
struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
224214
const struct ethtool_ops *et_ops,
225-
struct device *dev,
215+
struct pci_dev *pdev,
226216
struct aq_pci_func_s *aq_pci_func,
227217
unsigned int port,
228218
const struct aq_hw_ops *aq_hw_ops)
@@ -242,7 +232,7 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
242232
ndev->netdev_ops = ndev_ops;
243233
ndev->ethtool_ops = et_ops;
244234

245-
SET_NETDEV_DEV(ndev, dev);
235+
SET_NETDEV_DEV(ndev, &pdev->dev);
246236

247237
ndev->if_port = port;
248238
self->ndev = ndev;
@@ -254,7 +244,8 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
254244

255245
self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port,
256246
&self->aq_hw_ops);
257-
err = self->aq_hw_ops.get_hw_caps(self->aq_hw, &self->aq_hw_caps);
247+
err = self->aq_hw_ops.get_hw_caps(self->aq_hw, &self->aq_hw_caps,
248+
pdev->device, pdev->subsystem_device);
258249
if (err < 0)
259250
goto err_exit;
260251

@@ -749,16 +740,40 @@ int aq_nic_get_regs_count(struct aq_nic_s *self)
749740

750741
void aq_nic_get_stats(struct aq_nic_s *self, u64 *data)
751742
{
752-
struct aq_vec_s *aq_vec = NULL;
753743
unsigned int i = 0U;
754744
unsigned int count = 0U;
755-
int err = 0;
745+
struct aq_vec_s *aq_vec = NULL;
746+
struct aq_stats_s *stats = self->aq_hw_ops.hw_get_hw_stats(self->aq_hw);
756747

757-
err = self->aq_hw_ops.hw_get_hw_stats(self->aq_hw, data, &count);
758-
if (err < 0)
748+
if (!stats)
759749
goto err_exit;
760750

761-
data += count;
751+
data[i] = stats->uprc + stats->mprc + stats->bprc;
752+
data[++i] = stats->uprc;
753+
data[++i] = stats->mprc;
754+
data[++i] = stats->bprc;
755+
data[++i] = stats->erpt;
756+
data[++i] = stats->uptc + stats->mptc + stats->bptc;
757+
data[++i] = stats->uptc;
758+
data[++i] = stats->mptc;
759+
data[++i] = stats->bptc;
760+
data[++i] = stats->ubrc;
761+
data[++i] = stats->ubtc;
762+
data[++i] = stats->mbrc;
763+
data[++i] = stats->mbtc;
764+
data[++i] = stats->bbrc;
765+
data[++i] = stats->bbtc;
766+
data[++i] = stats->ubrc + stats->mbrc + stats->bbrc;
767+
data[++i] = stats->ubtc + stats->mbtc + stats->bbtc;
768+
data[++i] = stats->dma_pkt_rc;
769+
data[++i] = stats->dma_pkt_tc;
770+
data[++i] = stats->dma_oct_rc;
771+
data[++i] = stats->dma_oct_tc;
772+
data[++i] = stats->dpc;
773+
774+
i++;
775+
776+
data += i;
762777
count = 0U;
763778

764779
for (i = 0U, aq_vec = self->aq_vec[0];
@@ -768,7 +783,20 @@ void aq_nic_get_stats(struct aq_nic_s *self, u64 *data)
768783
}
769784

770785
err_exit:;
771-
(void)err;
786+
}
787+
788+
static void aq_nic_update_ndev_stats(struct aq_nic_s *self)
789+
{
790+
struct net_device *ndev = self->ndev;
791+
struct aq_stats_s *stats = self->aq_hw_ops.hw_get_hw_stats(self->aq_hw);
792+
793+
ndev->stats.rx_packets = stats->uprc + stats->mprc + stats->bprc;
794+
ndev->stats.rx_bytes = stats->ubrc + stats->mbrc + stats->bbrc;
795+
ndev->stats.rx_errors = stats->erpr;
796+
ndev->stats.tx_packets = stats->uptc + stats->mptc + stats->bptc;
797+
ndev->stats.tx_bytes = stats->ubtc + stats->mbtc + stats->bbtc;
798+
ndev->stats.tx_errors = stats->erpt;
799+
ndev->stats.multicast = stats->mprc;
772800
}
773801

774802
void aq_nic_get_link_ksettings(struct aq_nic_s *self,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct aq_nic_cfg_s {
7171

7272
struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
7373
const struct ethtool_ops *et_ops,
74-
struct device *dev,
74+
struct pci_dev *pdev,
7575
struct aq_pci_func_s *aq_pci_func,
7676
unsigned int port,
7777
const struct aq_hw_ops *aq_hw_ops);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ struct aq_pci_func_s *aq_pci_func_alloc(struct aq_hw_ops *aq_hw_ops,
5151
pci_set_drvdata(pdev, self);
5252
self->pdev = pdev;
5353

54-
err = aq_hw_ops->get_hw_caps(NULL, &self->aq_hw_caps);
54+
err = aq_hw_ops->get_hw_caps(NULL, &self->aq_hw_caps, pdev->device,
55+
pdev->subsystem_device);
5556
if (err < 0)
5657
goto err_exit;
5758

5859
self->ports = self->aq_hw_caps.ports;
5960

6061
for (port = 0; port < self->ports; ++port) {
6162
struct aq_nic_s *aq_nic = aq_nic_alloc_cold(ndev_ops, eth_ops,
62-
&pdev->dev, self,
63+
pdev, self,
6364
port, aq_hw_ops);
6465

6566
if (!aq_nic) {

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@
1818
#include "hw_atl_a0_internal.h"
1919

2020
static int hw_atl_a0_get_hw_caps(struct aq_hw_s *self,
21-
struct aq_hw_caps_s *aq_hw_caps)
21+
struct aq_hw_caps_s *aq_hw_caps,
22+
unsigned short device,
23+
unsigned short subsystem_device)
2224
{
2325
memcpy(aq_hw_caps, &hw_atl_a0_hw_caps_, sizeof(*aq_hw_caps));
26+
27+
if (device == HW_ATL_DEVICE_ID_D108 && subsystem_device == 0x0001)
28+
aq_hw_caps->link_speed_msk &= ~HW_ATL_A0_RATE_10G;
29+
30+
if (device == HW_ATL_DEVICE_ID_D109 && subsystem_device == 0x0001) {
31+
aq_hw_caps->link_speed_msk &= ~HW_ATL_A0_RATE_10G;
32+
aq_hw_caps->link_speed_msk &= ~HW_ATL_A0_RATE_5G;
33+
}
34+
2435
return 0;
2536
}
2637

@@ -333,6 +344,10 @@ static int hw_atl_a0_hw_init(struct aq_hw_s *self,
333344
hw_atl_a0_hw_rss_set(self, &aq_nic_cfg->aq_rss);
334345
hw_atl_a0_hw_rss_hash_set(self, &aq_nic_cfg->aq_rss);
335346

347+
/* Reset link status and read out initial hardware counters */
348+
self->aq_link_status.mbps = 0;
349+
hw_atl_utils_update_stats(self);
350+
336351
err = aq_hw_err_from_flags(self);
337352
if (err < 0)
338353
goto err_exit;

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,23 @@
1616
#include "hw_atl_utils.h"
1717
#include "hw_atl_llh.h"
1818
#include "hw_atl_b0_internal.h"
19+
#include "hw_atl_llh_internal.h"
1920

2021
static int hw_atl_b0_get_hw_caps(struct aq_hw_s *self,
21-
struct aq_hw_caps_s *aq_hw_caps)
22+
struct aq_hw_caps_s *aq_hw_caps,
23+
unsigned short device,
24+
unsigned short subsystem_device)
2225
{
2326
memcpy(aq_hw_caps, &hw_atl_b0_hw_caps_, sizeof(*aq_hw_caps));
27+
28+
if (device == HW_ATL_DEVICE_ID_D108 && subsystem_device == 0x0001)
29+
aq_hw_caps->link_speed_msk &= ~HW_ATL_B0_RATE_10G;
30+
31+
if (device == HW_ATL_DEVICE_ID_D109 && subsystem_device == 0x0001) {
32+
aq_hw_caps->link_speed_msk &= ~HW_ATL_B0_RATE_10G;
33+
aq_hw_caps->link_speed_msk &= ~HW_ATL_B0_RATE_5G;
34+
}
35+
2436
return 0;
2537
}
2638

@@ -357,6 +369,7 @@ static int hw_atl_b0_hw_init(struct aq_hw_s *self,
357369
};
358370

359371
int err = 0;
372+
u32 val;
360373

361374
self->aq_nic_cfg = aq_nic_cfg;
362375

@@ -374,6 +387,20 @@ static int hw_atl_b0_hw_init(struct aq_hw_s *self,
374387
hw_atl_b0_hw_rss_set(self, &aq_nic_cfg->aq_rss);
375388
hw_atl_b0_hw_rss_hash_set(self, &aq_nic_cfg->aq_rss);
376389

390+
/* Force limit MRRS on RDM/TDM to 2K */
391+
val = aq_hw_read_reg(self, pci_reg_control6_adr);
392+
aq_hw_write_reg(self, pci_reg_control6_adr, (val & ~0x707) | 0x404);
393+
394+
/* TX DMA total request limit. B0 hardware is not capable to
395+
* handle more than (8K-MRRS) incoming DMA data.
396+
* Value 24 in 256byte units
397+
*/
398+
aq_hw_write_reg(self, tx_dma_total_req_limit_adr, 24);
399+
400+
/* Reset link status and read out initial hardware counters */
401+
self->aq_link_status.mbps = 0;
402+
hw_atl_utils_update_stats(self);
403+
377404
err = aq_hw_err_from_flags(self);
378405
if (err < 0)
379406
goto err_exit;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,6 +2343,9 @@
23432343
#define tx_dma_desc_base_addrmsw_adr(descriptor) \
23442344
(0x00007c04u + (descriptor) * 0x40)
23452345

2346+
/* tx dma total request limit */
2347+
#define tx_dma_total_req_limit_adr 0x00007b20u
2348+
23462349
/* tx interrupt moderation control register definitions
23472350
* Preprocessor definitions for TX Interrupt Moderation Control Register
23482351
* Base Address: 0x00008980
@@ -2369,6 +2372,9 @@
23692372
/* default value of bitfield reg_res_dsbl */
23702373
#define pci_reg_res_dsbl_default 0x1
23712374

2375+
/* PCI core control register */
2376+
#define pci_reg_control6_adr 0x1014u
2377+
23722378
/* global microprocessor scratch pad definitions */
23732379
#define glb_cpu_scratch_scp_adr(scratch_scp) (0x00000300u + (scratch_scp) * 0x4)
23742380

0 commit comments

Comments
 (0)