Skip to content

Commit 4948293

Browse files
caildavem330
authored andcommitted
net: aquantia: Introduce new AQC devices and capabilities
A number of new AQC devices is going to be released. To support more flexible capabilities management a number of static caps instances is now declared. Devices now are mainly differs by supported speeds, but in future more parameters will be customized. A set of AQC100 devices have fibre media, not twisted pair - this is also reflected in new capabilities definitions. HW level also now directly exports hw_ops for each of A0/B0 hardware. PCI configuration now uses a device configuration table where each device ID is explicitly mapped with hardware OPs and capabilities structures. Signed-off-by: Igor Russkikh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent efe779b commit 4948293

File tree

12 files changed

+239
-159
lines changed

12 files changed

+239
-159
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646

4747
#define HW_ATL_NIC_NAME "aQuantia AQtion 10Gbit Network Adapter"
4848

49+
#define AQ_HWREV_ANY 0
50+
#define AQ_HWREV_1 1
51+
#define AQ_HWREV_2 2
52+
4953
#define AQ_NIC_RATE_10G BIT(0)
5054
#define AQ_NIC_RATE_5G BIT(1)
5155
#define AQ_NIC_RATE_5GSR BIT(2)

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ struct aq_hw_caps_s {
2323
u64 hw_features;
2424
u64 link_speed_msk;
2525
unsigned int hw_priv_flags;
26+
u32 media_type;
2627
u32 rxds;
2728
u32 txds;
2829
u32 txhwb_alignment;
@@ -95,6 +96,9 @@ struct aq_stats_s {
9596
#define AQ_NIC_FLAGS_IS_NOT_TX_READY (AQ_NIC_FLAGS_IS_NOT_READY | \
9697
AQ_NIC_LINK_DOWN)
9798

99+
#define AQ_HW_MEDIA_TYPE_TP 1U
100+
#define AQ_HW_MEDIA_TYPE_FIBRE 2U
101+
98102
struct aq_hw_s {
99103
atomic_t flags;
100104
struct aq_nic_cfg_s *aq_nic_cfg;
@@ -128,11 +132,6 @@ struct aq_hw_ops {
128132

129133
void (*destroy)(struct aq_hw_s *self);
130134

131-
int (*get_hw_caps)(struct aq_hw_s *self,
132-
struct aq_hw_caps_s *aq_hw_caps,
133-
unsigned short device,
134-
unsigned short subsystem_device);
135-
136135
int (*hw_ring_tx_xmit)(struct aq_hw_s *self, struct aq_ring_s *aq_ring,
137136
unsigned int frags);
138137

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ static void aq_nic_polling_timer_cb(struct timer_list *t)
208208
struct aq_nic_s *aq_nic_alloc_cold(struct pci_dev *pdev,
209209
struct aq_pci_func_s *aq_pci_func,
210210
unsigned int port,
211-
const struct aq_hw_ops *aq_hw_ops)
211+
const struct aq_hw_ops *aq_hw_ops,
212+
const struct aq_hw_caps_s *aq_hw_caps)
212213
{
213214
struct net_device *ndev = NULL;
214215
struct aq_nic_s *self = NULL;
@@ -230,16 +231,12 @@ struct aq_nic_s *aq_nic_alloc_cold(struct pci_dev *pdev,
230231
self->aq_pci_func = aq_pci_func;
231232

232233
self->aq_hw_ops = *aq_hw_ops;
234+
self->aq_hw_caps = *aq_hw_caps;
233235
self->port = (u8)port;
234236

235237
self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port);
236238
self->aq_hw->aq_nic_cfg = &self->aq_nic_cfg;
237239

238-
err = self->aq_hw_ops.get_hw_caps(self->aq_hw, &self->aq_hw_caps,
239-
pdev->device, pdev->subsystem_device);
240-
if (err < 0)
241-
goto err_exit;
242-
243240
aq_nic_cfg_init_defaults(self);
244241

245242
err_exit:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ static inline struct device *aq_nic_get_dev(struct aq_nic_s *self)
9292
struct aq_nic_s *aq_nic_alloc_cold(struct pci_dev *pdev,
9393
struct aq_pci_func_s *aq_pci_func,
9494
unsigned int port,
95-
const struct aq_hw_ops *aq_hw_ops);
95+
const struct aq_hw_ops *aq_hw_ops,
96+
const struct aq_hw_caps_s *aq_hw_caps);
9697
int aq_nic_ndev_init(struct aq_nic_s *self);
9798
struct aq_nic_s *aq_nic_alloc_hot(struct net_device *ndev);
9899
void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,

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

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,66 @@ static const struct pci_device_id aq_pci_tbl[] = {
6060
{}
6161
};
6262

63+
const struct aq_board_revision_s hw_atl_boards[] = {
64+
{ AQ_DEVICE_ID_0001, AQ_HWREV_1, &hw_atl_ops_a0, &hw_atl_a0_caps_aqc107, },
65+
{ AQ_DEVICE_ID_D100, AQ_HWREV_1, &hw_atl_ops_a0, &hw_atl_a0_caps_aqc100, },
66+
{ AQ_DEVICE_ID_D107, AQ_HWREV_1, &hw_atl_ops_a0, &hw_atl_a0_caps_aqc107, },
67+
{ AQ_DEVICE_ID_D108, AQ_HWREV_1, &hw_atl_ops_a0, &hw_atl_a0_caps_aqc108, },
68+
{ AQ_DEVICE_ID_D109, AQ_HWREV_1, &hw_atl_ops_a0, &hw_atl_a0_caps_aqc109, },
69+
70+
{ AQ_DEVICE_ID_0001, AQ_HWREV_2, &hw_atl_ops_b0, &hw_atl_b0_caps_aqc107, },
71+
{ AQ_DEVICE_ID_D100, AQ_HWREV_2, &hw_atl_ops_b0, &hw_atl_b0_caps_aqc100, },
72+
{ AQ_DEVICE_ID_D107, AQ_HWREV_2, &hw_atl_ops_b0, &hw_atl_b0_caps_aqc107, },
73+
{ AQ_DEVICE_ID_D108, AQ_HWREV_2, &hw_atl_ops_b0, &hw_atl_b0_caps_aqc108, },
74+
{ AQ_DEVICE_ID_D109, AQ_HWREV_2, &hw_atl_ops_b0, &hw_atl_b0_caps_aqc109, },
75+
76+
{ AQ_DEVICE_ID_AQC100, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc107, },
77+
{ AQ_DEVICE_ID_AQC107, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc107, },
78+
{ AQ_DEVICE_ID_AQC108, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc108, },
79+
{ AQ_DEVICE_ID_AQC109, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc109, },
80+
{ AQ_DEVICE_ID_AQC111, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc111, },
81+
{ AQ_DEVICE_ID_AQC112, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc112, },
82+
83+
{ AQ_DEVICE_ID_AQC100S, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc100s, },
84+
{ AQ_DEVICE_ID_AQC107S, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc107s, },
85+
{ AQ_DEVICE_ID_AQC108S, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc108s, },
86+
{ AQ_DEVICE_ID_AQC109S, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc109s, },
87+
{ AQ_DEVICE_ID_AQC111S, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc111s, },
88+
{ AQ_DEVICE_ID_AQC112S, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc112s, },
89+
90+
{ AQ_DEVICE_ID_AQC111E, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc111e, },
91+
{ AQ_DEVICE_ID_AQC112E, AQ_HWREV_ANY, &hw_atl_ops_b1, &hw_atl_b0_caps_aqc112e, },
92+
};
93+
6394
MODULE_DEVICE_TABLE(pci, aq_pci_tbl);
6495

65-
static const struct aq_hw_ops *aq_pci_probe_get_hw_ops_by_id(struct pci_dev *pdev)
96+
static int aq_pci_probe_get_hw_by_id(struct pci_dev *pdev,
97+
const struct aq_hw_ops **ops,
98+
const struct aq_hw_caps_s **caps)
6699
{
67-
const struct aq_hw_ops *ops = NULL;
100+
int i = 0;
101+
102+
if (pdev->vendor != PCI_VENDOR_ID_AQUANTIA)
103+
return -EINVAL;
104+
105+
for (i = 0; i < ARRAY_SIZE(hw_atl_boards); i++) {
106+
if (hw_atl_boards[i].devid == pdev->device &&
107+
(hw_atl_boards[i].revision == AQ_HWREV_ANY ||
108+
hw_atl_boards[i].revision == pdev->revision)) {
109+
*ops = hw_atl_boards[i].ops;
110+
*caps = hw_atl_boards[i].caps;
111+
break;
112+
}
113+
}
68114

69-
ops = hw_atl_a0_get_ops_by_id(pdev);
70-
if (!ops)
71-
ops = hw_atl_b0_get_ops_by_id(pdev);
115+
if (i == ARRAY_SIZE(hw_atl_boards))
116+
return -EINVAL;
72117

73-
return ops;
118+
return 0;
74119
}
75120

76121
struct aq_pci_func_s *aq_pci_func_alloc(const struct aq_hw_ops *aq_hw_ops,
122+
const struct aq_hw_caps_s *aq_hw_caps,
77123
struct pci_dev *pdev)
78124
{
79125
struct aq_pci_func_s *self = NULL;
@@ -92,17 +138,14 @@ struct aq_pci_func_s *aq_pci_func_alloc(const struct aq_hw_ops *aq_hw_ops,
92138

93139
pci_set_drvdata(pdev, self);
94140
self->pdev = pdev;
95-
96-
err = aq_hw_ops->get_hw_caps(NULL, &self->aq_hw_caps, pdev->device,
97-
pdev->subsystem_device);
98-
if (err < 0)
99-
goto err_exit;
141+
self->aq_hw_caps = *aq_hw_caps;
100142

101143
self->ports = self->aq_hw_caps.ports;
102144

103145
for (port = 0; port < self->ports; ++port) {
104146
struct aq_nic_s *aq_nic = aq_nic_alloc_cold(pdev, self,
105-
port, aq_hw_ops);
147+
port, aq_hw_ops,
148+
aq_hw_caps);
106149

107150
if (!aq_nic) {
108151
err = -ENOMEM;
@@ -343,14 +386,17 @@ static int aq_pci_probe(struct pci_dev *pdev,
343386
const struct pci_device_id *pci_id)
344387
{
345388
const struct aq_hw_ops *aq_hw_ops = NULL;
389+
const struct aq_hw_caps_s *aq_hw_caps = NULL;
346390
struct aq_pci_func_s *aq_pci_func = NULL;
347391
int err = 0;
348392

349393
err = pci_enable_device(pdev);
350394
if (err < 0)
351395
goto err_exit;
352-
aq_hw_ops = aq_pci_probe_get_hw_ops_by_id(pdev);
353-
aq_pci_func = aq_pci_func_alloc(aq_hw_ops, pdev);
396+
err = aq_pci_probe_get_hw_by_id(pdev, &aq_hw_ops, &aq_hw_caps);
397+
if (err < 0)
398+
goto err_exit;
399+
aq_pci_func = aq_pci_func_alloc(aq_hw_ops, aq_hw_caps, pdev);
354400
if (!aq_pci_func) {
355401
err = -ENOMEM;
356402
goto err_exit;

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@
1515
#include "aq_common.h"
1616
#include "aq_nic.h"
1717

18-
struct aq_pci_func_s *aq_pci_func_alloc(const struct aq_hw_ops *hw_ops,
19-
struct pci_dev *pdev);
18+
struct aq_board_revision_s {
19+
unsigned short devid;
20+
unsigned short revision;
21+
const struct aq_hw_ops *ops;
22+
const struct aq_hw_caps_s *caps;
23+
};
24+
2025
int aq_pci_func_init(struct aq_pci_func_s *self);
2126
int aq_pci_func_alloc_irq(struct aq_pci_func_s *self, unsigned int i,
2227
char *name, void *aq_vec,

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

Lines changed: 59 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,67 @@
1818
#include "hw_atl_llh.h"
1919
#include "hw_atl_a0_internal.h"
2020

21-
static int hw_atl_a0_get_hw_caps(struct aq_hw_s *self,
22-
struct aq_hw_caps_s *aq_hw_caps,
23-
unsigned short device,
24-
unsigned short subsystem_device)
25-
{
26-
memcpy(aq_hw_caps, &hw_atl_a0_hw_caps_, sizeof(*aq_hw_caps));
21+
#define DEFAULT_A0_BOARD_BASIC_CAPABILITIES \
22+
.is_64_dma = true, \
23+
.msix_irqs = 4U, \
24+
.irq_mask = ~0U, \
25+
.vecs = HW_ATL_A0_RSS_MAX, \
26+
.tcs = HW_ATL_A0_TC_MAX, \
27+
.rxd_alignment = 1U, \
28+
.rxd_size = HW_ATL_A0_RXD_SIZE, \
29+
.rxds = 248U, \
30+
.txd_alignment = 1U, \
31+
.txd_size = HW_ATL_A0_TXD_SIZE, \
32+
.txds = 8U * 1024U, \
33+
.txhwb_alignment = 4096U, \
34+
.tx_rings = HW_ATL_A0_TX_RINGS, \
35+
.rx_rings = HW_ATL_A0_RX_RINGS, \
36+
.hw_features = NETIF_F_HW_CSUM | \
37+
NETIF_F_RXHASH | \
38+
NETIF_F_RXCSUM | \
39+
NETIF_F_SG | \
40+
NETIF_F_TSO, \
41+
.hw_priv_flags = IFF_UNICAST_FLT, \
42+
.flow_control = true, \
43+
.mtu = HW_ATL_A0_MTU_JUMBO, \
44+
.mac_regs_count = 88
45+
46+
const struct aq_hw_caps_s hw_atl_a0_caps_aqc100 = {
47+
DEFAULT_A0_BOARD_BASIC_CAPABILITIES,
48+
.media_type = AQ_HW_MEDIA_TYPE_FIBRE,
49+
.link_speed_msk = HW_ATL_A0_RATE_5G |
50+
HW_ATL_A0_RATE_2G5 |
51+
HW_ATL_A0_RATE_1G |
52+
HW_ATL_A0_RATE_100M,
53+
};
2754

28-
if (device == AQ_DEVICE_ID_D108 && subsystem_device == 0x0001)
29-
aq_hw_caps->link_speed_msk &= ~AQ_NIC_RATE_10G;
55+
const struct aq_hw_caps_s hw_atl_a0_caps_aqc107 = {
56+
DEFAULT_A0_BOARD_BASIC_CAPABILITIES,
57+
.media_type = AQ_HW_MEDIA_TYPE_TP,
58+
.link_speed_msk = HW_ATL_A0_RATE_10G |
59+
HW_ATL_A0_RATE_5G |
60+
HW_ATL_A0_RATE_2G5 |
61+
HW_ATL_A0_RATE_1G |
62+
HW_ATL_A0_RATE_100M,
63+
};
3064

31-
if (device == AQ_DEVICE_ID_D109 && subsystem_device == 0x0001) {
32-
aq_hw_caps->link_speed_msk &= ~AQ_NIC_RATE_10G;
33-
aq_hw_caps->link_speed_msk &= ~AQ_NIC_RATE_5G;
34-
}
65+
const struct aq_hw_caps_s hw_atl_a0_caps_aqc108 = {
66+
DEFAULT_A0_BOARD_BASIC_CAPABILITIES,
67+
.media_type = AQ_HW_MEDIA_TYPE_TP,
68+
.link_speed_msk = HW_ATL_A0_RATE_5G |
69+
HW_ATL_A0_RATE_2G5 |
70+
HW_ATL_A0_RATE_1G |
71+
HW_ATL_A0_RATE_100M,
72+
};
73+
74+
const struct aq_hw_caps_s hw_atl_a0_caps_aqc109 = {
75+
DEFAULT_A0_BOARD_BASIC_CAPABILITIES,
76+
.media_type = AQ_HW_MEDIA_TYPE_TP,
77+
.link_speed_msk = HW_ATL_A0_RATE_2G5 |
78+
HW_ATL_A0_RATE_1G |
79+
HW_ATL_A0_RATE_100M,
80+
};
3581

36-
return 0;
37-
}
3882

3983
static struct aq_hw_s *hw_atl_a0_create(struct aq_pci_func_s *aq_pci_func,
4084
unsigned int port)
@@ -861,11 +905,9 @@ static int hw_atl_a0_hw_set_speed(struct aq_hw_s *self, u32 speed)
861905
return err;
862906
}
863907

864-
static const struct aq_hw_ops hw_atl_ops_ = {
908+
const struct aq_hw_ops hw_atl_ops_a0 = {
865909
.create = hw_atl_a0_create,
866910
.destroy = hw_atl_a0_destroy,
867-
.get_hw_caps = hw_atl_a0_get_hw_caps,
868-
869911
.hw_get_mac_permanent = hw_atl_utils_get_mac_permanent,
870912
.hw_set_mac_address = hw_atl_a0_hw_mac_addr_set,
871913
.hw_get_link_status = hw_atl_utils_mpi_get_link_status,
@@ -903,17 +945,3 @@ static const struct aq_hw_ops hw_atl_ops_ = {
903945
.hw_get_hw_stats = hw_atl_utils_get_hw_stats,
904946
.hw_get_fw_version = hw_atl_utils_get_fw_version,
905947
};
906-
907-
const struct aq_hw_ops *hw_atl_a0_get_ops_by_id(struct pci_dev *pdev)
908-
{
909-
bool is_vid_ok = (pdev->vendor == PCI_VENDOR_ID_AQUANTIA);
910-
bool is_did_ok = ((pdev->device == AQ_DEVICE_ID_0001) ||
911-
(pdev->device == AQ_DEVICE_ID_D100) ||
912-
(pdev->device == AQ_DEVICE_ID_D107) ||
913-
(pdev->device == AQ_DEVICE_ID_D108) ||
914-
(pdev->device == AQ_DEVICE_ID_D109));
915-
916-
bool is_rev_ok = (pdev->revision == 1U);
917-
918-
return (is_vid_ok && is_did_ok && is_rev_ok) ? &hw_atl_ops_ : NULL;
919-
}

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
#include "../aq_common.h"
1818

19-
const struct aq_hw_ops *hw_atl_a0_get_ops_by_id(struct pci_dev *pdev);
19+
extern const struct aq_hw_caps_s hw_atl_a0_caps_aqc100;
20+
extern const struct aq_hw_caps_s hw_atl_a0_caps_aqc107;
21+
extern const struct aq_hw_caps_s hw_atl_a0_caps_aqc108;
22+
extern const struct aq_hw_caps_s hw_atl_a0_caps_aqc109;
23+
24+
extern const struct aq_hw_ops hw_atl_ops_a0;
2025

2126
#endif /* HW_ATL_A0_H */

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

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
#define HW_ATL_A0_MPI_SPEED_MSK 0xFFFFU
6363
#define HW_ATL_A0_MPI_SPEED_SHIFT 16U
6464

65+
#define HW_ATL_A0_RATE_10G BIT(0)
66+
#define HW_ATL_A0_RATE_5G BIT(1)
67+
#define HW_ATL_A0_RATE_2G5 BIT(3)
68+
#define HW_ATL_A0_RATE_1G BIT(4)
69+
#define HW_ATL_A0_RATE_100M BIT(5)
70+
6571
#define HW_ATL_A0_TXBUF_MAX 160U
6672
#define HW_ATL_A0_RXBUF_MAX 320U
6773

@@ -82,38 +88,4 @@
8288

8389
#define HW_ATL_A0_FW_VER_EXPECTED 0x01050006U
8490

85-
/* HW layer capabilities */
86-
static struct aq_hw_caps_s hw_atl_a0_hw_caps_ = {
87-
.ports = 1U,
88-
.is_64_dma = true,
89-
.msix_irqs = 4U,
90-
.irq_mask = ~0U,
91-
.vecs = HW_ATL_A0_RSS_MAX,
92-
.tcs = HW_ATL_A0_TC_MAX,
93-
.rxd_alignment = 1U,
94-
.rxd_size = HW_ATL_A0_RXD_SIZE,
95-
.rxds = 248U,
96-
.txd_alignment = 1U,
97-
.txd_size = HW_ATL_A0_TXD_SIZE,
98-
.txds = 8U * 1024U,
99-
.txhwb_alignment = 4096U,
100-
.tx_rings = HW_ATL_A0_TX_RINGS,
101-
.rx_rings = HW_ATL_A0_RX_RINGS,
102-
.hw_features = NETIF_F_HW_CSUM |
103-
NETIF_F_RXCSUM |
104-
NETIF_F_RXHASH |
105-
NETIF_F_SG |
106-
NETIF_F_TSO,
107-
.hw_priv_flags = IFF_UNICAST_FLT,
108-
.link_speed_msk = (AQ_NIC_RATE_10G |
109-
AQ_NIC_RATE_5G |
110-
AQ_NIC_RATE_2GS |
111-
AQ_NIC_RATE_1G |
112-
AQ_NIC_RATE_100M),
113-
.flow_control = true,
114-
.mtu = HW_ATL_A0_MTU_JUMBO,
115-
.mac_regs_count = 88,
116-
.fw_ver_expected = HW_ATL_A0_FW_VER_EXPECTED,
117-
};
118-
11991
#endif /* HW_ATL_A0_INTERNAL_H */

0 commit comments

Comments
 (0)