igc: Add netdev
Subsystems (2)
PATCH v6 3/11 igc: Add netdev
Now that we have the ability to configure the basic settings on the device we can start allocating and configuring a netdev for the interface.
Sasha Neftin (v2):
add description
Sasha Neftin (v3):
minor cosmetic changes
Sasha Neftin (v4):
address comments
fix code indentation
replace e1000_ prefix with igc_ prefix
optimize pcie access
Sasha Neftin (v5):
change return value of igc_up() method to void
Sasha Neftin (v6):
fix define of MAX_Q_VECTORS
fix code indentation
minor cosmetic changes
--- drivers/net/ethernet/intel/igc/igc.h | 48 ++ drivers/net/ethernet/intel/igc/igc_defines.h | 15 + drivers/net/ethernet/intel/igc/igc_hw.h | 1 + drivers/net/ethernet/intel/igc/igc_main.c | 475 ++++++++++++++++++- 4 files changed, 537 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +48 -0
@@ -28,15 +28,63 @@extern char igc_driver_name[];extern char igc_driver_version[]; +/* Transmit and receive queues */ +#define IGC_MAX_RX_QUEUES 4 +#define IGC_MAX_TX_QUEUES 4 + +#define MAX_Q_VECTORS 8 +#define MAX_STD_JUMBO_FRAME_SIZE 9216 + +enum igc_state_t { + __IGC_TESTING, + __IGC_RESETTING, + __IGC_DOWN, + __IGC_PTP_TX_IN_PROGRESS, +}; + +struct igc_q_vector { +struct igc_adapter *adapter;/* backlink */ + +struct napi_struct napi; +}; + +struct igc_mac_addr { +u8 addr[ETH_ALEN ]; +u8 queue; +u8 state;/* bitmask */ +}; + +#define IGC_MAC_STATE_DEFAULT 0x1 +#define IGC_MAC_STATE_MODIFIED 0x2 +#define IGC_MAC_STATE_IN_USE 0x4 +/* Board specific private data structure */ struct igc_adapter { +struct net_device *netdev; + +unsigned long state; +unsigned int flags; +unsigned int num_q_vectors; +u16 link_speed; +u16 link_duplex; + +u8 port_num; +u8 __iomem *io_addr; +struct work_struct watchdog_task; + +int msg_enable; +u32 max_frame_size;/* OS defined structs */ struct pci_dev *pdev;/* structs defined in igc_hw.h */ struct igc_hw hw; + +struct igc_q_vector *q_vector[MAX_Q_VECTORS ]; + +struct igc_mac_addr *mac_table; };#endif /* _IGC_H_ */
drivers/net/ethernet/intel/igc/igc_defines.h +15 -0
@@ -4,6 +4,8 @@#ifndef _IGC_DEFINES_H_#define _IGC_DEFINES_H_ +#define IGC_CTRL_EXT_DRV_LOAD 0x10000000/* Drv loaded bit for FW */ +/* PCI Function Mask */ #define IGC_STATUS_FUNC_MASK 0x0000000C
@@ -11,6 +13,16 @@#define PCIE_DEVICE_CONTROL2 0x28#define PCIE_DEVICE_CONTROL2_16ms 0x0005 +/* Receive Address +* Number of high/low register pairs in the RAR. The RAR (Receive Address +* Registers) holds the directed and multicast addresses that we monitor. +* Technically, we have 16 spots. However, we reserve one of these spots +* (RAR[15]) for our directed address used by controllers with +* manageability enabled, allowing us room for 15 multicast addresses. +*/ +#define IGC_RAH_AV 0x80000000/* Receive descriptor valid */ +#define IGC_RAH_POOL_1 0x00040000 +/* Error Codes */ #define IGC_SUCCESS 0#define IGC_ERR_NVM 1
@@ -20,6 +32,9 @@#define IGC_ERR_MAC_INIT 5#define IGC_ERR_RESET 9 +/* PBA constants */ +#define IGC_PBA_34K 0x0022 +/* Device Status */ #define IGC_STATUS_FD 0x00000001/* Full duplex.0=half,1=full */ #define IGC_STATUS_LU 0x00000002/* Link up.0=no,1=link */
drivers/net/ethernet/intel/igc/igc_hw.h +1 -0
@@ -84,6 +84,7 @@ struct igc_mac_info {bool autoneg;bool autoneg_failed; +bool get_link_status; };struct igc_bus_info {
drivers/net/ethernet/intel/igc/igc_main.c +473 -2
553 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH v6 3/11 igc: Add netdev
On 8/23/2018 12:05 AM, Sasha Neftin wrote:
[...]
Quoted 1 line
drivers/net/ethernet/intel/igc/igc_main.c +1
-0+strncpy (netdev->name,pci_name (pdev),sizeof (netdev->name) -1 );
[...]
drivers/net/ethernet/intel/igc/igc_main.c static int igc_probe(struct pci_dev *pdev, · line 578
Quoted 1 line
drivers/net/ethernet/intel/igc/igc_main.c +1
-0+strncpy (netdev->name,"eth%d" ,IFNAMSIZ );
I've mentioned this to you before: why are you setting the netdev->name twice, and to different values? Besides, the OS's udev rules will likely change the name to something else.
drivers/net/ethernet/intel/igc/igc_main.c MODULE_AUTHOR("Intel Corporation, <[email protected]>"); · line 718
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_main.c +3
-0+ +module_param (debug, int,0 ); +MODULE_PARM_DESC (debug,"Debug level (0=none,...,16=all)" );/* igc_main.c */
It would be nice to have this up above, next to the definition of int debug.
sln
Neftin
PATCH v6 3/11 igc: Add netdev
Quoted 6 lines · Shannon Nelson
On 8/23/2018 12:05 AM, Sasha Neftin wrote:
[...]
Quoted 1 line
+???
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);
Quoted 8 lines
[...]
Quoted 1 line
+???
strncpy(netdev->name, "eth%d", IFNAMSIZ);I've mentioned this to you before: why are you setting the
netdev->nametwice, and to different values?? Besides, the OS's udev rules will likely change the name to something else.
I believe I already answered in previous review (v3 or v4). Since I remove second settings of netdev->name: "strncpy(netdev->name, "eth%d", IFNAMSIZ)" I got error in probe: "probe of 0000:05:00.0 failed with error -22". I agree with you that we can do some optimization here - I will look later again in this code.
Quoted 9 lines
Quoted 5 lines
drivers/net/ethernet/intel/igc/igc_main.c +3
-0+ +module_param (debug, int,0 ); +MODULE_PARM_DESC (debug,"Debug level (0=none,...,16=all)" );? /*
igc_main.c*/It would be nice to have this up above, next to the definition of int debug.
so, may be all code start from MODULE_AUTHOR... move to begin of the file. it is not urgent. I will look at other examples. what is benefit from this?
Quoted 2 lines
sln
Sasha
Neftin
PATCH v6 3/11 igc: Add netdev
Quoted 15 lines · Sasha
Quoted 6 lines · Shannon Nelson
On 8/23/2018 12:05 AM, Sasha Neftin wrote:
[...]
Quoted 1 line
+???
strncpy(netdev->name, pci_name(pdev), sizeof(netdev->name) - 1);Quoted 8 lines
[...]
Quoted 1 line
+???
strncpy(netdev->name, "eth%d", IFNAMSIZ);I've mentioned this to you before: why are you setting the
netdev->nametwice, and to different values?? Besides, the OS's udev rules will likely change the name to something else.
Quoted 6 lines
I believe I already answered in previous review (v3 or v4). Since I remove second settings of
netdev->name: "strncpy(netdev->name, "eth%d", IFNAMSIZ)" I got error in probe: "probe of 0000:05:00.0 failed with error -22". I agree with you that we can do some optimization here - I will look later again in this code.Quoted 1 line
Thanks that you point me on this. I figure out that 'strncpy(netdev->name, pci_name(pdev)...' line have no point and should be removed. Since v6 should be final I will consult with Jeff how to submit change, probably in different patch. Also, we need run validation cycle.
Quoted 18 lines
Quoted 8 lines
Quoted 4 lines
drivers/net/ethernet/intel/igc/igc_main.c +3
-0+ +module_param (debug, int,0 ); +MODULE_PARM_DESC (debug,"Debug level (0=none,...,16=all)" );? /*
igc_main.c*/It would be nice to have this up above, next to the definition of int debug.
so, may be all code start from
MODULE_AUTHOR... move to begin of the file. it is not urgent. I will look at other examples. what is benefit from this?Quoted 2 lines
sln
Sasha
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan at osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan