Skip to content

Commit 10a435a

Browse files
committed
Merge branch 'aquantia-next'
Igor Russkikh says: ==================== Aquantia atlantic driver update 2018/01 This patch is a set of cleanups and bugfixes in preparation to new Aquantia hardware support. Standard ARRAY_SIZE is now used through all the code, some unused abstraction structures removed and cleaned up, duplicate declarations removed. Also two large declaration styling fixes: - Hardware register set defines are lined up with kernel style - Hardware access functions were not prefixed, now already defined hw_atl prefix is used. patch v2 changes: - patch reorganized because of its big size. New HW support will be submitted as a separate patchset. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 3b039b4 + 9ec03bf commit 10a435a

26 files changed

+2385
-2334
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include <linux/pci.h>
1717

1818
#include "ver.h"
19-
#include "aq_nic.h"
2019
#include "aq_cfg.h"
2120
#include "aq_utils.h"
2221

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
* version 2, as published by the Free Software Foundation.
88
*/
99

10-
/* File aq_hw.h: Declaraion of abstract interface for NIC hardware specific
10+
/* File aq_hw.h: Declaration of abstract interface for NIC hardware specific
1111
* functions.
1212
*/
1313

1414
#ifndef AQ_HW_H
1515
#define AQ_HW_H
1616

1717
#include "aq_common.h"
18+
#include "aq_rss.h"
19+
#include "hw_atl/hw_atl_utils.h"
1820

1921
/* NIC H/W capabilities */
2022
struct aq_hw_caps_s {
@@ -86,13 +88,33 @@ struct aq_stats_s {
8688

8789
#define AQ_HW_FLAG_ERRORS (AQ_HW_FLAG_ERR_HW | AQ_HW_FLAG_ERR_UNPLUG)
8890

91+
#define AQ_NIC_FLAGS_IS_NOT_READY (AQ_NIC_FLAG_STOPPING | \
92+
AQ_NIC_FLAG_RESETTING | AQ_NIC_FLAG_CLOSING | \
93+
AQ_NIC_FLAG_ERR_UNPLUG | AQ_NIC_FLAG_ERR_HW)
94+
95+
#define AQ_NIC_FLAGS_IS_NOT_TX_READY (AQ_NIC_FLAGS_IS_NOT_READY | \
96+
AQ_NIC_LINK_DOWN)
97+
8998
struct aq_hw_s {
90-
struct aq_obj_s header;
99+
atomic_t flags;
91100
struct aq_nic_cfg_s *aq_nic_cfg;
92101
struct aq_pci_func_s *aq_pci_func;
93102
void __iomem *mmio;
94103
unsigned int not_ff_addr;
95104
struct aq_hw_link_status_s aq_link_status;
105+
struct hw_aq_atl_utils_mbox mbox;
106+
struct hw_atl_stats_s last_stats;
107+
struct aq_stats_s curr_stats;
108+
u64 speed;
109+
u32 itr_tx;
110+
u32 itr_rx;
111+
unsigned int chip_features;
112+
u32 fw_ver_actual;
113+
atomic_t dpc;
114+
u32 mbox_addr;
115+
u32 rpc_addr;
116+
u32 rpc_tid;
117+
struct hw_aq_atl_utils_fw_rpc rpc;
96118
};
97119

98120
struct aq_ring_s;
@@ -102,7 +124,7 @@ struct sk_buff;
102124

103125
struct aq_hw_ops {
104126
struct aq_hw_s *(*create)(struct aq_pci_func_s *aq_pci_func,
105-
unsigned int port, struct aq_hw_ops *ops);
127+
unsigned int port);
106128

107129
void (*destroy)(struct aq_hw_s *self);
108130

@@ -124,7 +146,6 @@ struct aq_hw_ops {
124146
struct aq_ring_s *aq_ring);
125147

126148
int (*hw_get_mac_permanent)(struct aq_hw_s *self,
127-
struct aq_hw_caps_s *aq_hw_caps,
128149
u8 *mac);
129150

130151
int (*hw_set_mac_address)(struct aq_hw_s *self, u8 *mac_addr);
@@ -135,8 +156,7 @@ struct aq_hw_ops {
135156

136157
int (*hw_reset)(struct aq_hw_s *self);
137158

138-
int (*hw_init)(struct aq_hw_s *self, struct aq_nic_cfg_s *aq_nic_cfg,
139-
u8 *mac_addr);
159+
int (*hw_init)(struct aq_hw_s *self, u8 *mac_addr);
140160

141161
int (*hw_start)(struct aq_hw_s *self);
142162

@@ -184,7 +204,8 @@ struct aq_hw_ops {
184204
struct aq_rss_parameters *rss_params);
185205

186206
int (*hw_get_regs)(struct aq_hw_s *self,
187-
struct aq_hw_caps_s *aq_hw_caps, u32 *regs_buff);
207+
const struct aq_hw_caps_s *aq_hw_caps,
208+
u32 *regs_buff);
188209

189210
int (*hw_update_stats)(struct aq_hw_s *self);
190211

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg)
4040
u32 value = readl(hw->mmio + reg);
4141

4242
if ((~0U) == value && (~0U) == readl(hw->mmio + hw->not_ff_addr))
43-
aq_utils_obj_set(&hw->header.flags, AQ_HW_FLAG_ERR_UNPLUG);
43+
aq_utils_obj_set(&hw->flags, AQ_HW_FLAG_ERR_UNPLUG);
4444

4545
return value;
4646
}
@@ -54,11 +54,11 @@ int aq_hw_err_from_flags(struct aq_hw_s *hw)
5454
{
5555
int err = 0;
5656

57-
if (aq_utils_obj_test(&hw->header.flags, AQ_HW_FLAG_ERR_UNPLUG)) {
57+
if (aq_utils_obj_test(&hw->flags, AQ_HW_FLAG_ERR_UNPLUG)) {
5858
err = -ENXIO;
5959
goto err_exit;
6060
}
61-
if (aq_utils_obj_test(&hw->header.flags, AQ_HW_FLAG_ERR_HW)) {
61+
if (aq_utils_obj_test(&hw->flags, AQ_HW_FLAG_ERR_HW)) {
6262
err = -EIO;
6363
goto err_exit;
6464
}

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

Lines changed: 14 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,32 @@
1313
#include "aq_nic.h"
1414
#include "aq_pci_func.h"
1515
#include "aq_ethtool.h"
16-
#include "hw_atl/hw_atl_a0.h"
17-
#include "hw_atl/hw_atl_b0.h"
1816

1917
#include <linux/netdevice.h>
2018
#include <linux/module.h>
2119

22-
static const struct pci_device_id aq_pci_tbl[] = {
23-
{ PCI_VDEVICE(AQUANTIA, HW_ATL_DEVICE_ID_0001), },
24-
{ PCI_VDEVICE(AQUANTIA, HW_ATL_DEVICE_ID_D100), },
25-
{ PCI_VDEVICE(AQUANTIA, HW_ATL_DEVICE_ID_D107), },
26-
{ PCI_VDEVICE(AQUANTIA, HW_ATL_DEVICE_ID_D108), },
27-
{ PCI_VDEVICE(AQUANTIA, HW_ATL_DEVICE_ID_D109), },
28-
{}
29-
};
30-
31-
MODULE_DEVICE_TABLE(pci, aq_pci_tbl);
32-
3320
MODULE_LICENSE("GPL v2");
3421
MODULE_VERSION(AQ_CFG_DRV_VERSION);
3522
MODULE_AUTHOR(AQ_CFG_DRV_AUTHOR);
3623
MODULE_DESCRIPTION(AQ_CFG_DRV_DESC);
3724

38-
static struct aq_hw_ops *aq_pci_probe_get_hw_ops_by_id(struct pci_dev *pdev)
25+
static const struct net_device_ops aq_ndev_ops;
26+
27+
struct net_device *aq_ndev_alloc(void)
3928
{
40-
struct aq_hw_ops *ops = NULL;
29+
struct net_device *ndev = NULL;
30+
struct aq_nic_s *aq_nic = NULL;
4131

42-
ops = hw_atl_a0_get_ops_by_id(pdev);
43-
if (!ops)
44-
ops = hw_atl_b0_get_ops_by_id(pdev);
32+
ndev = alloc_etherdev_mq(sizeof(struct aq_nic_s), AQ_CFG_VECS_MAX);
33+
if (!ndev)
34+
return NULL;
4535

46-
return ops;
36+
aq_nic = netdev_priv(ndev);
37+
aq_nic->ndev = ndev;
38+
ndev->netdev_ops = &aq_ndev_ops;
39+
ndev->ethtool_ops = &aq_ethtool_ops;
40+
41+
return ndev;
4742
}
4843

4944
static int aq_ndev_open(struct net_device *ndev)
@@ -170,66 +165,3 @@ static const struct net_device_ops aq_ndev_ops = {
170165
.ndo_set_mac_address = aq_ndev_set_mac_address,
171166
.ndo_set_features = aq_ndev_set_features
172167
};
173-
174-
static int aq_pci_probe(struct pci_dev *pdev,
175-
const struct pci_device_id *pci_id)
176-
{
177-
struct aq_hw_ops *aq_hw_ops = NULL;
178-
struct aq_pci_func_s *aq_pci_func = NULL;
179-
int err = 0;
180-
181-
err = pci_enable_device(pdev);
182-
if (err < 0)
183-
goto err_exit;
184-
aq_hw_ops = aq_pci_probe_get_hw_ops_by_id(pdev);
185-
aq_pci_func = aq_pci_func_alloc(aq_hw_ops, pdev,
186-
&aq_ndev_ops, &aq_ethtool_ops);
187-
if (!aq_pci_func) {
188-
err = -ENOMEM;
189-
goto err_exit;
190-
}
191-
err = aq_pci_func_init(aq_pci_func);
192-
if (err < 0)
193-
goto err_exit;
194-
195-
err_exit:
196-
if (err < 0) {
197-
if (aq_pci_func)
198-
aq_pci_func_free(aq_pci_func);
199-
}
200-
return err;
201-
}
202-
203-
static void aq_pci_remove(struct pci_dev *pdev)
204-
{
205-
struct aq_pci_func_s *aq_pci_func = pci_get_drvdata(pdev);
206-
207-
aq_pci_func_deinit(aq_pci_func);
208-
aq_pci_func_free(aq_pci_func);
209-
}
210-
211-
static int aq_pci_suspend(struct pci_dev *pdev, pm_message_t pm_msg)
212-
{
213-
struct aq_pci_func_s *aq_pci_func = pci_get_drvdata(pdev);
214-
215-
return aq_pci_func_change_pm_state(aq_pci_func, &pm_msg);
216-
}
217-
218-
static int aq_pci_resume(struct pci_dev *pdev)
219-
{
220-
struct aq_pci_func_s *aq_pci_func = pci_get_drvdata(pdev);
221-
pm_message_t pm_msg = PMSG_RESTORE;
222-
223-
return aq_pci_func_change_pm_state(aq_pci_func, &pm_msg);
224-
}
225-
226-
static struct pci_driver aq_pci_ops = {
227-
.name = AQ_CFG_DRV_NAME,
228-
.id_table = aq_pci_tbl,
229-
.probe = aq_pci_probe,
230-
.remove = aq_pci_remove,
231-
.suspend = aq_pci_suspend,
232-
.resume = aq_pci_resume,
233-
};
234-
235-
module_pci_driver(aq_pci_ops);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414

1515
#include "aq_common.h"
1616

17+
struct net_device *aq_ndev_alloc(void);
18+
1719
#endif /* AQ_MAIN_H */

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

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "aq_vec.h"
1515
#include "aq_hw.h"
1616
#include "aq_pci_func.h"
17-
#include "aq_nic_internal.h"
17+
#include "aq_main.h"
1818

1919
#include <linux/moduleparam.h>
2020
#include <linux/netdevice.h>
@@ -150,17 +150,17 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)
150150

151151
self->link_status = self->aq_hw->aq_link_status;
152152
if (!netif_carrier_ok(self->ndev) && self->link_status.mbps) {
153-
aq_utils_obj_set(&self->header.flags,
153+
aq_utils_obj_set(&self->flags,
154154
AQ_NIC_FLAG_STARTED);
155-
aq_utils_obj_clear(&self->header.flags,
155+
aq_utils_obj_clear(&self->flags,
156156
AQ_NIC_LINK_DOWN);
157157
netif_carrier_on(self->ndev);
158158
netif_tx_wake_all_queues(self->ndev);
159159
}
160160
if (netif_carrier_ok(self->ndev) && !self->link_status.mbps) {
161161
netif_carrier_off(self->ndev);
162162
netif_tx_disable(self->ndev);
163-
aq_utils_obj_set(&self->header.flags, AQ_NIC_LINK_DOWN);
163+
aq_utils_obj_set(&self->flags, AQ_NIC_LINK_DOWN);
164164
}
165165
return 0;
166166
}
@@ -171,7 +171,7 @@ static void aq_nic_service_timer_cb(struct timer_list *t)
171171
int ctimer = AQ_CFG_SERVICE_TIMER_INTERVAL;
172172
int err = 0;
173173

174-
if (aq_utils_obj_test(&self->header.flags, AQ_NIC_FLAGS_IS_NOT_READY))
174+
if (aq_utils_obj_test(&self->flags, AQ_NIC_FLAGS_IS_NOT_READY))
175175
goto err_exit;
176176

177177
err = aq_nic_update_link_status(self);
@@ -205,14 +205,7 @@ static void aq_nic_polling_timer_cb(struct timer_list *t)
205205
AQ_CFG_POLLING_TIMER_INTERVAL);
206206
}
207207

208-
static struct net_device *aq_nic_ndev_alloc(void)
209-
{
210-
return alloc_etherdev_mq(sizeof(struct aq_nic_s), AQ_CFG_VECS_MAX);
211-
}
212-
213-
struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
214-
const struct ethtool_ops *et_ops,
215-
struct pci_dev *pdev,
208+
struct aq_nic_s *aq_nic_alloc_cold(struct pci_dev *pdev,
216209
struct aq_pci_func_s *aq_pci_func,
217210
unsigned int port,
218211
const struct aq_hw_ops *aq_hw_ops)
@@ -221,17 +214,14 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
221214
struct aq_nic_s *self = NULL;
222215
int err = 0;
223216

224-
ndev = aq_nic_ndev_alloc();
217+
ndev = aq_ndev_alloc();
225218
if (!ndev) {
226219
err = -ENOMEM;
227220
goto err_exit;
228221
}
229222

230223
self = netdev_priv(ndev);
231224

232-
ndev->netdev_ops = ndev_ops;
233-
ndev->ethtool_ops = et_ops;
234-
235225
SET_NETDEV_DEV(ndev, &pdev->dev);
236226

237227
ndev->if_port = port;
@@ -242,8 +232,9 @@ struct aq_nic_s *aq_nic_alloc_cold(const struct net_device_ops *ndev_ops,
242232
self->aq_hw_ops = *aq_hw_ops;
243233
self->port = (u8)port;
244234

245-
self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port,
246-
&self->aq_hw_ops);
235+
self->aq_hw = self->aq_hw_ops.create(aq_pci_func, self->port);
236+
self->aq_hw->aq_nic_cfg = &self->aq_nic_cfg;
237+
247238
err = self->aq_hw_ops.get_hw_caps(self->aq_hw, &self->aq_hw_caps,
248239
pdev->device, pdev->subsystem_device);
249240
if (err < 0)
@@ -268,7 +259,6 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
268259
goto err_exit;
269260
}
270261
err = self->aq_hw_ops.hw_get_mac_permanent(self->aq_hw,
271-
self->aq_nic_cfg.aq_hw_caps,
272262
self->ndev->dev_addr);
273263
if (err < 0)
274264
goto err_exit;
@@ -295,7 +285,7 @@ int aq_nic_ndev_register(struct aq_nic_s *self)
295285

296286
int aq_nic_ndev_init(struct aq_nic_s *self)
297287
{
298-
struct aq_hw_caps_s *aq_hw_caps = self->aq_nic_cfg.aq_hw_caps;
288+
const struct aq_hw_caps_s *aq_hw_caps = self->aq_nic_cfg.aq_hw_caps;
299289
struct aq_nic_cfg_s *aq_nic_cfg = &self->aq_nic_cfg;
300290

301291
self->ndev->hw_features |= aq_hw_caps->hw_features;
@@ -366,11 +356,6 @@ void aq_nic_set_tx_ring(struct aq_nic_s *self, unsigned int idx,
366356
self->aq_ring_tx[idx] = ring;
367357
}
368358

369-
struct device *aq_nic_get_dev(struct aq_nic_s *self)
370-
{
371-
return self->ndev->dev.parent;
372-
}
373-
374359
struct net_device *aq_nic_get_ndev(struct aq_nic_s *self)
375360
{
376361
return self->ndev;
@@ -387,7 +372,7 @@ int aq_nic_init(struct aq_nic_s *self)
387372
if (err < 0)
388373
goto err_exit;
389374

390-
err = self->aq_hw_ops.hw_init(self->aq_hw, &self->aq_nic_cfg,
375+
err = self->aq_hw_ops.hw_init(self->aq_hw,
391376
aq_nic_get_ndev(self)->dev_addr);
392377
if (err < 0)
393378
goto err_exit;
@@ -992,7 +977,7 @@ void aq_nic_free_hot_resources(struct aq_nic_s *self)
992977
if (!self)
993978
goto err_exit;
994979

995-
for (i = AQ_DIMOF(self->aq_vec); i--;) {
980+
for (i = ARRAY_SIZE(self->aq_vec); i--;) {
996981
if (self->aq_vec[i]) {
997982
aq_vec_free(self->aq_vec[i]);
998983
self->aq_vec[i] = NULL;

0 commit comments

Comments
 (0)