Skip to content

Commit d89f884

Browse files
aneftinJeff Kirsher
authored andcommitted
igc: Add skeletal frame for Intel(R) 2.5G Ethernet Controller support
This patch adds the beginning framework onto which I am going to add the igc driver which supports the Intel(R) I225-LM/I225-V 2.5G Ethernet Controller. Signed-off-by: Sasha Neftin <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent aadd435 commit d89f884

File tree

6 files changed

+212
-0
lines changed

6 files changed

+212
-0
lines changed

drivers/net/ethernet/intel/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,20 @@ config FM10K
287287
To compile this driver as a module, choose M here. The module
288288
will be called fm10k. MSI-X interrupt support is required
289289

290+
config IGC
291+
tristate "Intel(R) Ethernet Controller I225-LM/I225-V support"
292+
default n
293+
depends on PCI
294+
---help---
295+
This driver supports Intel(R) Ethernet Controller I225-LM/I225-V
296+
family of adapters.
297+
298+
For more information on how to identify your adapter, go
299+
to the Adapter & Driver ID Guide that can be located at:
300+
301+
<http://support.intel.com>
302+
303+
To compile this driver as a module, choose M here. The module
304+
will be called igc.
305+
290306
endif # NET_VENDOR_INTEL

drivers/net/ethernet/intel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ obj-$(CONFIG_E100) += e100.o
77
obj-$(CONFIG_E1000) += e1000/
88
obj-$(CONFIG_E1000E) += e1000e/
99
obj-$(CONFIG_IGB) += igb/
10+
obj-$(CONFIG_IGC) += igc/
1011
obj-$(CONFIG_IGBVF) += igbvf/
1112
obj-$(CONFIG_IXGBE) += ixgbe/
1213
obj-$(CONFIG_IXGBEVF) += ixgbevf/
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
# Copyright (c) 2018 Intel Corporation
3+
4+
#
5+
# Intel(R) I225-LM/I225-V 2.5G Ethernet Controller
6+
#
7+
8+
obj-$(CONFIG_IGC) += igc.o
9+
10+
igc-objs := igc_main.o

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2018 Intel Corporation */
3+
4+
#ifndef _IGC_H_
5+
#define _IGC_H_
6+
7+
#include <linux/kobject.h>
8+
9+
#include <linux/pci.h>
10+
#include <linux/netdevice.h>
11+
#include <linux/vmalloc.h>
12+
13+
#include <linux/ethtool.h>
14+
15+
#include <linux/sctp.h>
16+
17+
#define IGC_ERR(args...) pr_err("igc: " args)
18+
19+
#define PFX "igc: "
20+
21+
#include <linux/timecounter.h>
22+
#include <linux/net_tstamp.h>
23+
#include <linux/ptp_clock_kernel.h>
24+
25+
/* main */
26+
extern char igc_driver_name[];
27+
extern char igc_driver_version[];
28+
29+
#endif /* _IGC_H_ */
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2018 Intel Corporation */
3+
4+
#ifndef _IGC_HW_H_
5+
#define _IGC_HW_H_
6+
7+
#define IGC_DEV_ID_I225_LM 0x15F2
8+
#define IGC_DEV_ID_I225_V 0x15F3
9+
10+
#endif /* _IGC_HW_H_ */
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) 2018 Intel Corporation */
3+
4+
#include <linux/module.h>
5+
#include <linux/types.h>
6+
7+
#include "igc.h"
8+
#include "igc_hw.h"
9+
10+
#define DRV_VERSION "0.0.1-k"
11+
#define DRV_SUMMARY "Intel(R) 2.5G Ethernet Linux Driver"
12+
13+
MODULE_AUTHOR("Intel Corporation, <[email protected]>");
14+
MODULE_DESCRIPTION(DRV_SUMMARY);
15+
MODULE_LICENSE("GPL v2");
16+
MODULE_VERSION(DRV_VERSION);
17+
18+
char igc_driver_name[] = "igc";
19+
char igc_driver_version[] = DRV_VERSION;
20+
static const char igc_driver_string[] = DRV_SUMMARY;
21+
static const char igc_copyright[] =
22+
"Copyright(c) 2018 Intel Corporation.";
23+
24+
static const struct pci_device_id igc_pci_tbl[] = {
25+
{ PCI_VDEVICE(INTEL, IGC_DEV_ID_I225_LM) },
26+
{ PCI_VDEVICE(INTEL, IGC_DEV_ID_I225_V) },
27+
/* required last entry */
28+
{0, }
29+
};
30+
31+
MODULE_DEVICE_TABLE(pci, igc_pci_tbl);
32+
33+
/**
34+
* igc_probe - Device Initialization Routine
35+
* @pdev: PCI device information struct
36+
* @ent: entry in igc_pci_tbl
37+
*
38+
* Returns 0 on success, negative on failure
39+
*
40+
* igc_probe initializes an adapter identified by a pci_dev structure.
41+
* The OS initialization, configuring the adapter private structure,
42+
* and a hardware reset occur.
43+
*/
44+
static int igc_probe(struct pci_dev *pdev,
45+
const struct pci_device_id *ent)
46+
{
47+
int err, pci_using_dac;
48+
49+
err = pci_enable_device_mem(pdev);
50+
if (err)
51+
return err;
52+
53+
pci_using_dac = 0;
54+
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));
55+
if (!err) {
56+
err = dma_set_coherent_mask(&pdev->dev,
57+
DMA_BIT_MASK(64));
58+
if (!err)
59+
pci_using_dac = 1;
60+
} else {
61+
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
62+
if (err) {
63+
err = dma_set_coherent_mask(&pdev->dev,
64+
DMA_BIT_MASK(32));
65+
if (err) {
66+
IGC_ERR("Wrong DMA configuration, aborting\n");
67+
goto err_dma;
68+
}
69+
}
70+
}
71+
72+
err = pci_request_selected_regions(pdev,
73+
pci_select_bars(pdev,
74+
IORESOURCE_MEM),
75+
igc_driver_name);
76+
if (err)
77+
goto err_pci_reg;
78+
79+
pci_set_master(pdev);
80+
err = pci_save_state(pdev);
81+
return 0;
82+
83+
err_pci_reg:
84+
err_dma:
85+
pci_disable_device(pdev);
86+
return err;
87+
}
88+
89+
/**
90+
* igc_remove - Device Removal Routine
91+
* @pdev: PCI device information struct
92+
*
93+
* igc_remove is called by the PCI subsystem to alert the driver
94+
* that it should release a PCI device. This could be caused by a
95+
* Hot-Plug event, or because the driver is going to be removed from
96+
* memory.
97+
*/
98+
static void igc_remove(struct pci_dev *pdev)
99+
{
100+
pci_release_selected_regions(pdev,
101+
pci_select_bars(pdev, IORESOURCE_MEM));
102+
103+
pci_disable_device(pdev);
104+
}
105+
106+
static struct pci_driver igc_driver = {
107+
.name = igc_driver_name,
108+
.id_table = igc_pci_tbl,
109+
.probe = igc_probe,
110+
.remove = igc_remove,
111+
};
112+
113+
/**
114+
* igc_init_module - Driver Registration Routine
115+
*
116+
* igc_init_module is the first routine called when the driver is
117+
* loaded. All it does is register with the PCI subsystem.
118+
*/
119+
static int __init igc_init_module(void)
120+
{
121+
int ret;
122+
123+
pr_info("%s - version %s\n",
124+
igc_driver_string, igc_driver_version);
125+
126+
pr_info("%s\n", igc_copyright);
127+
128+
ret = pci_register_driver(&igc_driver);
129+
return ret;
130+
}
131+
132+
module_init(igc_init_module);
133+
134+
/**
135+
* igc_exit_module - Driver Exit Cleanup Routine
136+
*
137+
* igc_exit_module is called just before the driver is removed
138+
* from memory.
139+
*/
140+
static void __exit igc_exit_module(void)
141+
{
142+
pci_unregister_driver(&igc_driver);
143+
}
144+
145+
module_exit(igc_exit_module);
146+
/* igc_main.c */

0 commit comments

Comments
 (0)