forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <anirudh.venkataramanan@intel.com> Tested-by: Tony Brelinski <tonyx.brelinski@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
- Loading branch information
1 parent
996bfed
commit 837f08f
Showing
9 changed files
with
304 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
Intel(R) Ethernet Connection E800 Series Linux Driver | ||
=================================================================== | ||
|
||
Intel ice Linux driver. | ||
Copyright(c) 2018 Intel Corporation. | ||
|
||
Contents | ||
======== | ||
- Enabling the driver | ||
- Support | ||
|
||
The driver in this release supports Intel's E800 Series of products. For | ||
more information, visit Intel's support page at http://support.intel.com. | ||
|
||
Enabling the driver | ||
=================== | ||
|
||
The driver is enabled via the standard kernel configuration system, | ||
using the make command: | ||
|
||
Make oldconfig/silentoldconfig/menuconfig/etc. | ||
|
||
The driver is located in the menu structure at: | ||
|
||
-> Device Drivers | ||
-> Network device support (NETDEVICES [=y]) | ||
-> Ethernet driver support | ||
-> Intel devices | ||
-> Intel(R) Ethernet Connection E800 Series Support | ||
|
||
Support | ||
======= | ||
|
||
For general information, go to the Intel support website at: | ||
|
||
http://support.intel.com | ||
|
||
If an issue is identified with the released source code, please email | ||
the maintainer listed in the MAINTAINERS file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# Copyright (c) 2018, Intel Corporation. | ||
|
||
# | ||
# Makefile for the Intel(R) Ethernet Connection E800 Series Linux Driver | ||
# | ||
|
||
obj-$(CONFIG_ICE) += ice.o | ||
|
||
ice-y := ice_main.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) 2018, Intel Corporation. */ | ||
|
||
#ifndef _ICE_H_ | ||
#define _ICE_H_ | ||
|
||
#include <linux/types.h> | ||
#include <linux/errno.h> | ||
#include <linux/kernel.h> | ||
#include <linux/module.h> | ||
#include <linux/netdevice.h> | ||
#include <linux/compiler.h> | ||
#include <linux/pci.h> | ||
#include <linux/aer.h> | ||
#include <linux/bitmap.h> | ||
#include "ice_devids.h" | ||
#include "ice_type.h" | ||
|
||
#define ICE_BAR0 0 | ||
|
||
#define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) | ||
|
||
enum ice_state { | ||
__ICE_DOWN, | ||
__ICE_STATE_NBITS /* must be last */ | ||
}; | ||
|
||
struct ice_pf { | ||
struct pci_dev *pdev; | ||
DECLARE_BITMAP(state, __ICE_STATE_NBITS); | ||
u32 msg_enable; | ||
struct ice_hw hw; | ||
}; | ||
#endif /* _ICE_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) 2018, Intel Corporation. */ | ||
|
||
#ifndef _ICE_DEVIDS_H_ | ||
#define _ICE_DEVIDS_H_ | ||
|
||
/* Device IDs */ | ||
/* Intel(R) Ethernet Controller C810 for backplane */ | ||
#define ICE_DEV_ID_C810_BACKPLANE 0x1591 | ||
/* Intel(R) Ethernet Controller C810 for QSFP */ | ||
#define ICE_DEV_ID_C810_QSFP 0x1592 | ||
/* Intel(R) Ethernet Controller C810 for SFP */ | ||
#define ICE_DEV_ID_C810_SFP 0x1593 | ||
/* Intel(R) Ethernet Controller C810/X557-AT 10GBASE-T */ | ||
#define ICE_DEV_ID_C810_10G_BASE_T 0x1594 | ||
/* Intel(R) Ethernet Controller C810 1GbE */ | ||
#define ICE_DEV_ID_C810_SGMII 0x1595 | ||
|
||
#endif /* _ICE_DEVIDS_H_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
/* Copyright (c) 2018, Intel Corporation. */ | ||
|
||
/* Intel(R) Ethernet Connection E800 Series Linux Driver */ | ||
|
||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
|
||
#include "ice.h" | ||
|
||
#define DRV_VERSION "ice-0.0.1-k" | ||
#define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver" | ||
static const char ice_drv_ver[] = DRV_VERSION; | ||
static const char ice_driver_string[] = DRV_SUMMARY; | ||
static const char ice_copyright[] = "Copyright (c) 2018, Intel Corporation."; | ||
|
||
MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>"); | ||
MODULE_DESCRIPTION(DRV_SUMMARY); | ||
MODULE_LICENSE("GPL"); | ||
MODULE_VERSION(DRV_VERSION); | ||
|
||
static int debug = -1; | ||
module_param(debug, int, 0644); | ||
MODULE_PARM_DESC(debug, "netif message level (0=none,...,0x7FFF=all)"); | ||
|
||
/** | ||
* ice_probe - Device initialization routine | ||
* @pdev: PCI device information struct | ||
* @ent: entry in ice_pci_tbl | ||
* | ||
* Returns 0 on success, negative on failure | ||
*/ | ||
static int ice_probe(struct pci_dev *pdev, | ||
const struct pci_device_id __always_unused *ent) | ||
{ | ||
struct ice_pf *pf; | ||
struct ice_hw *hw; | ||
int err; | ||
|
||
/* this driver uses devres, see Documentation/driver-model/devres.txt */ | ||
err = pcim_enable_device(pdev); | ||
if (err) | ||
return err; | ||
|
||
err = pcim_iomap_regions(pdev, BIT(ICE_BAR0), pci_name(pdev)); | ||
if (err) { | ||
dev_err(&pdev->dev, "I/O map error %d\n", err); | ||
return err; | ||
} | ||
|
||
pf = devm_kzalloc(&pdev->dev, sizeof(*pf), GFP_KERNEL); | ||
if (!pf) | ||
return -ENOMEM; | ||
|
||
/* set up for high or low dma */ | ||
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); | ||
if (err) | ||
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); | ||
if (err) { | ||
dev_err(&pdev->dev, "DMA configuration failed: 0x%x\n", err); | ||
return err; | ||
} | ||
|
||
pci_enable_pcie_error_reporting(pdev); | ||
pci_set_master(pdev); | ||
|
||
pf->pdev = pdev; | ||
pci_set_drvdata(pdev, pf); | ||
set_bit(__ICE_DOWN, pf->state); | ||
|
||
hw = &pf->hw; | ||
hw->hw_addr = pcim_iomap_table(pdev)[ICE_BAR0]; | ||
hw->back = pf; | ||
hw->vendor_id = pdev->vendor; | ||
hw->device_id = pdev->device; | ||
pci_read_config_byte(pdev, PCI_REVISION_ID, &hw->revision_id); | ||
hw->subsystem_vendor_id = pdev->subsystem_vendor; | ||
hw->subsystem_device_id = pdev->subsystem_device; | ||
hw->bus.device = PCI_SLOT(pdev->devfn); | ||
hw->bus.func = PCI_FUNC(pdev->devfn); | ||
pf->msg_enable = netif_msg_init(debug, ICE_DFLT_NETIF_M); | ||
|
||
return 0; | ||
} | ||
|
||
/** | ||
* ice_remove - Device removal routine | ||
* @pdev: PCI device information struct | ||
*/ | ||
static void ice_remove(struct pci_dev *pdev) | ||
{ | ||
struct ice_pf *pf = pci_get_drvdata(pdev); | ||
|
||
if (!pf) | ||
return; | ||
|
||
set_bit(__ICE_DOWN, pf->state); | ||
pci_disable_pcie_error_reporting(pdev); | ||
} | ||
|
||
/* ice_pci_tbl - PCI Device ID Table | ||
* | ||
* Wildcard entries (PCI_ANY_ID) should come last | ||
* Last entry must be all 0s | ||
* | ||
* { Vendor ID, Device ID, SubVendor ID, SubDevice ID, | ||
* Class, Class Mask, private data (not used) } | ||
*/ | ||
static const struct pci_device_id ice_pci_tbl[] = { | ||
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_BACKPLANE), 0 }, | ||
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_QSFP), 0 }, | ||
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_SFP), 0 }, | ||
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_10G_BASE_T), 0 }, | ||
{ PCI_VDEVICE(INTEL, ICE_DEV_ID_C810_SGMII), 0 }, | ||
/* required last entry */ | ||
{ 0, } | ||
}; | ||
MODULE_DEVICE_TABLE(pci, ice_pci_tbl); | ||
|
||
static struct pci_driver ice_driver = { | ||
.name = KBUILD_MODNAME, | ||
.id_table = ice_pci_tbl, | ||
.probe = ice_probe, | ||
.remove = ice_remove, | ||
}; | ||
|
||
/** | ||
* ice_module_init - Driver registration routine | ||
* | ||
* ice_module_init is the first routine called when the driver is | ||
* loaded. All it does is register with the PCI subsystem. | ||
*/ | ||
static int __init ice_module_init(void) | ||
{ | ||
int status; | ||
|
||
pr_info("%s - version %s\n", ice_driver_string, ice_drv_ver); | ||
pr_info("%s\n", ice_copyright); | ||
|
||
status = pci_register_driver(&ice_driver); | ||
if (status) | ||
pr_err("failed to register pci driver, err %d\n", status); | ||
|
||
return status; | ||
} | ||
module_init(ice_module_init); | ||
|
||
/** | ||
* ice_module_exit - Driver exit cleanup routine | ||
* | ||
* ice_module_exit is called just before the driver is removed | ||
* from memory. | ||
*/ | ||
static void __exit ice_module_exit(void) | ||
{ | ||
pci_unregister_driver(&ice_driver); | ||
pr_info("module unloaded\n"); | ||
} | ||
module_exit(ice_module_exit); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (c) 2018, Intel Corporation. */ | ||
|
||
#ifndef _ICE_TYPE_H_ | ||
#define _ICE_TYPE_H_ | ||
|
||
/* Bus parameters */ | ||
struct ice_bus_info { | ||
u16 device; | ||
u8 func; | ||
}; | ||
|
||
/* Port hardware description */ | ||
struct ice_hw { | ||
u8 __iomem *hw_addr; | ||
void *back; | ||
|
||
/* pci info */ | ||
u16 device_id; | ||
u16 vendor_id; | ||
u16 subsystem_device_id; | ||
u16 subsystem_vendor_id; | ||
u8 revision_id; | ||
|
||
struct ice_bus_info bus; | ||
}; | ||
|
||
#endif /* _ICE_TYPE_H_ */ |