Skip to content

Commit 837f08f

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Add basic driver framework for Intel(R) E800 Series
This patch adds a basic driver framework for the Intel(R) E800 Ethernet Series of network devices. There is no functionality right now other than the ability to load. Signed-off-by: Anirudh Venkataramanan <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 996bfed commit 837f08f

File tree

9 files changed

+304
-0
lines changed

9 files changed

+304
-0
lines changed

Documentation/networking/ice.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Intel(R) Ethernet Connection E800 Series Linux Driver
2+
===================================================================
3+
4+
Intel ice Linux driver.
5+
Copyright(c) 2018 Intel Corporation.
6+
7+
Contents
8+
========
9+
- Enabling the driver
10+
- Support
11+
12+
The driver in this release supports Intel's E800 Series of products. For
13+
more information, visit Intel's support page at http://support.intel.com.
14+
15+
Enabling the driver
16+
===================
17+
18+
The driver is enabled via the standard kernel configuration system,
19+
using the make command:
20+
21+
Make oldconfig/silentoldconfig/menuconfig/etc.
22+
23+
The driver is located in the menu structure at:
24+
25+
-> Device Drivers
26+
-> Network device support (NETDEVICES [=y])
27+
-> Ethernet driver support
28+
-> Intel devices
29+
-> Intel(R) Ethernet Connection E800 Series Support
30+
31+
Support
32+
=======
33+
34+
For general information, go to the Intel support website at:
35+
36+
http://support.intel.com
37+
38+
If an issue is identified with the released source code, please email
39+
the maintainer listed in the MAINTAINERS file.

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7063,6 +7063,7 @@ F: Documentation/networking/ixgbe.txt
70637063
F: Documentation/networking/ixgbevf.txt
70647064
F: Documentation/networking/i40e.txt
70657065
F: Documentation/networking/i40evf.txt
7066+
F: Documentation/networking/ice.txt
70667067
F: drivers/net/ethernet/intel/
70677068
F: drivers/net/ethernet/intel/*/
70687069
F: include/linux/avf/virtchnl.h

drivers/net/ethernet/intel/Kconfig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,20 @@ config I40EVF
251251
will be called i40evf. MSI-X interrupt support is required
252252
for this driver to work correctly.
253253

254+
config ICE
255+
tristate "Intel(R) Ethernet Connection E800 Series Support"
256+
default n
257+
depends on PCI_MSI
258+
---help---
259+
This driver supports Intel(R) Ethernet Connection E800 Series of
260+
devices. For more information on how to identify your adapter, go
261+
to the Adapter & Driver ID Guide that can be located at:
262+
263+
<http://support.intel.com>
264+
265+
To compile this driver as a module, choose M here. The module
266+
will be called ice.
267+
254268
config FM10K
255269
tristate "Intel(R) FM10000 Ethernet Switch Host Interface Support"
256270
default n

drivers/net/ethernet/intel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ obj-$(CONFIG_I40E) += i40e/
1414
obj-$(CONFIG_IXGB) += ixgb/
1515
obj-$(CONFIG_I40EVF) += i40evf/
1616
obj-$(CONFIG_FM10K) += fm10k/
17+
obj-$(CONFIG_ICE) += ice/
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+
# Makefile for the Intel(R) Ethernet Connection E800 Series Linux Driver
6+
#
7+
8+
obj-$(CONFIG_ICE) += ice.o
9+
10+
ice-y := ice_main.o

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2018, Intel Corporation. */
3+
4+
#ifndef _ICE_H_
5+
#define _ICE_H_
6+
7+
#include <linux/types.h>
8+
#include <linux/errno.h>
9+
#include <linux/kernel.h>
10+
#include <linux/module.h>
11+
#include <linux/netdevice.h>
12+
#include <linux/compiler.h>
13+
#include <linux/pci.h>
14+
#include <linux/aer.h>
15+
#include <linux/bitmap.h>
16+
#include "ice_devids.h"
17+
#include "ice_type.h"
18+
19+
#define ICE_BAR0 0
20+
21+
#define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
22+
23+
enum ice_state {
24+
__ICE_DOWN,
25+
__ICE_STATE_NBITS /* must be last */
26+
};
27+
28+
struct ice_pf {
29+
struct pci_dev *pdev;
30+
DECLARE_BITMAP(state, __ICE_STATE_NBITS);
31+
u32 msg_enable;
32+
struct ice_hw hw;
33+
};
34+
#endif /* _ICE_H_ */
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2018, Intel Corporation. */
3+
4+
#ifndef _ICE_DEVIDS_H_
5+
#define _ICE_DEVIDS_H_
6+
7+
/* Device IDs */
8+
/* Intel(R) Ethernet Controller C810 for backplane */
9+
#define ICE_DEV_ID_C810_BACKPLANE 0x1591
10+
/* Intel(R) Ethernet Controller C810 for QSFP */
11+
#define ICE_DEV_ID_C810_QSFP 0x1592
12+
/* Intel(R) Ethernet Controller C810 for SFP */
13+
#define ICE_DEV_ID_C810_SFP 0x1593
14+
/* Intel(R) Ethernet Controller C810/X557-AT 10GBASE-T */
15+
#define ICE_DEV_ID_C810_10G_BASE_T 0x1594
16+
/* Intel(R) Ethernet Controller C810 1GbE */
17+
#define ICE_DEV_ID_C810_SGMII 0x1595
18+
19+
#endif /* _ICE_DEVIDS_H_ */
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) 2018, Intel Corporation. */
3+
4+
/* Intel(R) Ethernet Connection E800 Series Linux Driver */
5+
6+
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
7+
8+
#include "ice.h"
9+
10+
#define DRV_VERSION "ice-0.0.1-k"
11+
#define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver"
12+
static const char ice_drv_ver[] = DRV_VERSION;
13+
static const char ice_driver_string[] = DRV_SUMMARY;
14+
static const char ice_copyright[] = "Copyright (c) 2018, Intel Corporation.";
15+
16+
MODULE_AUTHOR("Intel Corporation, <[email protected]>");
17+
MODULE_DESCRIPTION(DRV_SUMMARY);
18+
MODULE_LICENSE("GPL");
19+
MODULE_VERSION(DRV_VERSION);
20+
21+
static int debug = -1;
22+
module_param(debug, int, 0644);
23+
MODULE_PARM_DESC(debug, "netif message level (0=none,...,0x7FFF=all)");
24+
25+
/**
26+
* ice_probe - Device initialization routine
27+
* @pdev: PCI device information struct
28+
* @ent: entry in ice_pci_tbl
29+
*
30+
* Returns 0 on success, negative on failure
31+
*/
32+
static int ice_probe(struct pci_dev *pdev,
33+
const struct pci_device_id __always_unused *ent)
34+
{
35+
struct ice_pf *pf;
36+
struct ice_hw *hw;
37+
int err;
38+
39+
/* this driver uses devres, see Documentation/driver-model/devres.txt */
40+
err = pcim_enable_device(pdev);
41+
if (err)
42+
return err;
43+
44+
err = pcim_iomap_regions(pdev, BIT(ICE_BAR0), pci_name(pdev));
45+
if (err) {
46+
dev_err(&pdev->dev, "I/O map error %d\n", err);
47+
return err;
48+
}
49+
50+
pf = devm_kzalloc(&pdev->dev, sizeof(*pf), GFP_KERNEL);
51+
if (!pf)
52+
return -ENOMEM;
53+
54+
/* set up for high or low dma */
55+
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64));
56+
if (err)
57+
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
58+
if (err) {
59+
dev_err(&pdev->dev, "DMA configuration failed: 0x%x\n", err);
60+
return err;
61+
}
62+
63+
pci_enable_pcie_error_reporting(pdev);
64+
pci_set_master(pdev);
65+
66+
pf->pdev = pdev;
67+
pci_set_drvdata(pdev, pf);
68+
set_bit(__ICE_DOWN, pf->state);
69+
70+
hw = &pf->hw;
71+
hw->hw_addr = pcim_iomap_table(pdev)[ICE_BAR0];
72+
hw->back = pf;
73+
hw->vendor_id = pdev->vendor;
74+
hw->device_id = pdev->device;
75+
pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id);
76+
hw->subsystem_vendor_id = pdev->subsystem_vendor;
77+
hw->subsystem_device_id = pdev->subsystem_device;
78+
hw->bus.device = PCI_SLOT(pdev->devfn);
79+
hw->bus.func = PCI_FUNC(pdev->devfn);
80+
pf->msg_enable = netif_msg_init(debug, ICE_DFLT_NETIF_M);
81+
82+
return 0;
83+
}
84+
85+
/**
86+
* ice_remove - Device removal routine
87+
* @pdev: PCI device information struct
88+
*/
89+
static void ice_remove(struct pci_dev *pdev)
90+
{
91+
struct ice_pf *pf = pci_get_drvdata(pdev);
92+
93+
if (!pf)
94+
return;
95+
96+
set_bit(__ICE_DOWN, pf->state);
97+
pci_disable_pcie_error_reporting(pdev);
98+
}
99+
100+
/* ice_pci_tbl - PCI Device ID Table
101+
*
102+
* Wildcard entries (PCI_ANY_ID) should come last
103+
* Last entry must be all 0s
104+
*
105+
* { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
106+
* Class, Class Mask, private data (not used) }
107+
*/
108+
static const struct pci_device_id ice_pci_tbl[] = {
109+
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_BACKPLANE), 0 },
110+
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_QSFP), 0 },
111+
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_SFP), 0 },
112+
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_10G_BASE_T), 0 },
113+
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_SGMII), 0 },
114+
/* required last entry */
115+
{ 0, }
116+
};
117+
MODULE_DEVICE_TABLE(pci, ice_pci_tbl);
118+
119+
static struct pci_driver ice_driver = {
120+
.name = KBUILD_MODNAME,
121+
.id_table = ice_pci_tbl,
122+
.probe = ice_probe,
123+
.remove = ice_remove,
124+
};
125+
126+
/**
127+
* ice_module_init - Driver registration routine
128+
*
129+
* ice_module_init is the first routine called when the driver is
130+
* loaded. All it does is register with the PCI subsystem.
131+
*/
132+
static int __init ice_module_init(void)
133+
{
134+
int status;
135+
136+
pr_info("%s - version %s\n", ice_driver_string, ice_drv_ver);
137+
pr_info("%s\n", ice_copyright);
138+
139+
status = pci_register_driver(&ice_driver);
140+
if (status)
141+
pr_err("failed to register pci driver, err %d\n", status);
142+
143+
return status;
144+
}
145+
module_init(ice_module_init);
146+
147+
/**
148+
* ice_module_exit - Driver exit cleanup routine
149+
*
150+
* ice_module_exit is called just before the driver is removed
151+
* from memory.
152+
*/
153+
static void __exit ice_module_exit(void)
154+
{
155+
pci_unregister_driver(&ice_driver);
156+
pr_info("module unloaded\n");
157+
}
158+
module_exit(ice_module_exit);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
/* Copyright (c) 2018, Intel Corporation. */
3+
4+
#ifndef _ICE_TYPE_H_
5+
#define _ICE_TYPE_H_
6+
7+
/* Bus parameters */
8+
struct ice_bus_info {
9+
u16 device;
10+
u8 func;
11+
};
12+
13+
/* Port hardware description */
14+
struct ice_hw {
15+
u8 __iomem *hw_addr;
16+
void *back;
17+
18+
/* pci info */
19+
u16 device_id;
20+
u16 vendor_id;
21+
u16 subsystem_device_id;
22+
u16 subsystem_vendor_id;
23+
u8 revision_id;
24+
25+
struct ice_bus_info bus;
26+
};
27+
28+
#endif /* _ICE_TYPE_H_ */

0 commit comments

Comments
 (0)