-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Gerhard Engleder says: ==================== TSN endpoint Ethernet MAC driver This series adds a driver for my FPGA based TSN endpoint Ethernet MAC. It also includes the device tree binding. The device is designed as Ethernet MAC for TSN networks. It will be used in PLCs with real-time requirements up to isochronous communication with protocols like OPC UA Pub/Sub. v3: - set MAC mode based on PHY information (Andrew Lunn) - remove/postpone loopback mode interface (Andrew Lunn) - add suppress_preamble node support (Andrew Lunn) - add mdio timeout (Andrew Lunn) - no need to call phy_start_aneg (Andrew Lunn) - remove unreachable code (Andrew Lunn) - move 'struct napi_struct' closer to queues (Vinicius Costa Gomes) - remove unused variable (kernel test robot) - switch from mdio interrupt to polling - mdio register without PHY address flag - thread safe interrupt enable register - add PTP_1588_CLOCK_OPTIONAL dependency to Kconfig - introduce dmadev for DMA allocation - mdiobus for platforms without device tree - prepare MAC address support for platforms without device tree - add missing interrupt disable to probe error path v2: - add C45 check (Andrew Lunn) - forward phy_connect_direct() return value (Andrew Lunn) - use phy_remove_link_mode() (Andrew Lunn) - do not touch PHY directly, use PHY subsystem (Andrew Lunn) - remove management data lock (Andrew Lunn) - use phy_loopback (Andrew Lunn) - remove GMII2RGMII handling, use xgmiitorgmii (Andrew Lunn) - remove char device for direct TX/RX queue access (Andrew Lunn) - mdio node for mdiobus (Rob Herring) - simplify compatible node (Rob Herring) - limit number of items of reg and interrupts nodes (Rob Herring) - restrict phy-connection-type node (Rob Herring) - reference to mdio.yaml under mdio node (Rob Herring) - remove device tree (Michal Simek) - fix %llx warning (kernel test robot) - fix unused tmp variable warning (kernel test robot) - add missing of_node_put() for of_parse_phandle() - use devm_mdiobus_alloc() - simplify mdiobus read/write - reduce required nodes - ethtool priv flags interface for loopback - add missing static for some functions - remove obsolete hardware defines ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
- Loading branch information
Showing
13 changed files
with
3,592 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,79 @@ | ||
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) | ||
%YAML 1.2 | ||
--- | ||
$id: http://devicetree.org/schemas/net/engleder,tsnep.yaml# | ||
$schema: http://devicetree.org/meta-schemas/core.yaml# | ||
|
||
title: TSN endpoint Ethernet MAC binding | ||
|
||
maintainers: | ||
- Gerhard Engleder <gerhard@engleder-embedded.com> | ||
|
||
allOf: | ||
- $ref: ethernet-controller.yaml# | ||
|
||
properties: | ||
compatible: | ||
const: engleder,tsnep | ||
|
||
reg: | ||
maxItems: 1 | ||
|
||
interrupts: | ||
maxItems: 1 | ||
|
||
local-mac-address: true | ||
|
||
mac-address: true | ||
|
||
nvmem-cells: true | ||
|
||
nvmem-cells-names: true | ||
|
||
phy-connection-type: | ||
enum: | ||
- mii | ||
- gmii | ||
- rgmii | ||
- rgmii-id | ||
|
||
phy-mode: true | ||
|
||
phy-handle: true | ||
|
||
mdio: | ||
type: object | ||
$ref: "mdio.yaml#" | ||
description: optional node for embedded MDIO controller | ||
|
||
required: | ||
- compatible | ||
- reg | ||
- interrupts | ||
|
||
additionalProperties: false | ||
|
||
examples: | ||
- | | ||
axi { | ||
#address-cells = <2>; | ||
#size-cells = <2>; | ||
tnsep0: ethernet@a0000000 { | ||
compatible = "engleder,tsnep"; | ||
reg = <0x0 0xa0000000 0x0 0x10000>; | ||
interrupts = <0 89 1>; | ||
interrupt-parent = <&gic>; | ||
local-mac-address = [00 00 00 00 00 00]; | ||
phy-mode = "rgmii"; | ||
phy-handle = <&phy0>; | ||
mdio { | ||
#address-cells = <1>; | ||
#size-cells = <0>; | ||
suppress-preamble; | ||
phy0: ethernet-phy@1 { | ||
reg = <1>; | ||
rxc-skew-ps = <1080>; | ||
}; | ||
}; | ||
}; | ||
}; |
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,38 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# | ||
# Engleder network device configuration | ||
# | ||
|
||
config NET_VENDOR_ENGLEDER | ||
bool "Engleder devices" | ||
default y | ||
help | ||
If you have a network (Ethernet) card belonging to this class, say Y. | ||
|
||
Note that the answer to this question doesn't directly affect the | ||
kernel: saying N will just cause the configurator to skip all | ||
the questions about Engleder devices. If you say Y, you will be asked | ||
for your specific card in the following questions. | ||
|
||
if NET_VENDOR_ENGLEDER | ||
|
||
config TSNEP | ||
tristate "TSN endpoint support" | ||
depends on PTP_1588_CLOCK_OPTIONAL | ||
select PHYLIB | ||
help | ||
Support for the Engleder TSN endpoint Ethernet MAC IP Core. | ||
|
||
To compile this driver as a module, choose M here. The module will be | ||
called tsnep. | ||
|
||
config TSNEP_SELFTESTS | ||
bool "TSN endpoint self test support" | ||
default n | ||
depends on TSNEP | ||
help | ||
This enables self test support within the TSN endpoint driver. | ||
|
||
If unsure, say N. | ||
|
||
endif # NET_VENDOR_ENGLEDER |
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 | ||
# | ||
# Makefile for the Engleder Ethernet drivers | ||
# | ||
|
||
obj-$(CONFIG_TSNEP) += tsnep.o | ||
|
||
tsnep-objs := tsnep_main.o tsnep_ethtool.o tsnep_ptp.o tsnep_tc.o \ | ||
$(tsnep-y) | ||
tsnep-$(CONFIG_TSNEP_SELFTESTS) += tsnep_selftests.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,190 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
/* Copyright (C) 2021 Gerhard Engleder <gerhard@engleder-embedded.com> */ | ||
|
||
#ifndef _TSNEP_H | ||
#define _TSNEP_H | ||
|
||
#include "tsnep_hw.h" | ||
|
||
#include <linux/platform_device.h> | ||
#include <linux/dma-mapping.h> | ||
#include <linux/etherdevice.h> | ||
#include <linux/phy.h> | ||
#include <linux/ethtool.h> | ||
#include <linux/net_tstamp.h> | ||
#include <linux/ptp_clock_kernel.h> | ||
#include <linux/miscdevice.h> | ||
|
||
#define TSNEP "tsnep" | ||
|
||
#define TSNEP_RING_SIZE 256 | ||
#define TSNEP_RING_ENTRIES_PER_PAGE (PAGE_SIZE / TSNEP_DESC_SIZE) | ||
#define TSNEP_RING_PAGE_COUNT (TSNEP_RING_SIZE / TSNEP_RING_ENTRIES_PER_PAGE) | ||
|
||
#define TSNEP_QUEUES 1 | ||
|
||
struct tsnep_gcl { | ||
void __iomem *addr; | ||
|
||
u64 base_time; | ||
u64 cycle_time; | ||
u64 cycle_time_extension; | ||
|
||
struct tsnep_gcl_operation operation[TSNEP_GCL_COUNT]; | ||
int count; | ||
|
||
u64 change_limit; | ||
|
||
u64 start_time; | ||
bool change; | ||
}; | ||
|
||
struct tsnep_tx_entry { | ||
struct tsnep_tx_desc *desc; | ||
struct tsnep_tx_desc_wb *desc_wb; | ||
dma_addr_t desc_dma; | ||
bool owner_user_flag; | ||
|
||
u32 properties; | ||
|
||
struct sk_buff *skb; | ||
size_t len; | ||
DEFINE_DMA_UNMAP_ADDR(dma); | ||
}; | ||
|
||
struct tsnep_tx { | ||
struct tsnep_adapter *adapter; | ||
void __iomem *addr; | ||
|
||
void *page[TSNEP_RING_PAGE_COUNT]; | ||
dma_addr_t page_dma[TSNEP_RING_PAGE_COUNT]; | ||
|
||
/* TX ring lock */ | ||
spinlock_t lock; | ||
struct tsnep_tx_entry entry[TSNEP_RING_SIZE]; | ||
int write; | ||
int read; | ||
u32 owner_counter; | ||
int increment_owner_counter; | ||
|
||
u32 packets; | ||
u32 bytes; | ||
u32 dropped; | ||
}; | ||
|
||
struct tsnep_rx_entry { | ||
struct tsnep_rx_desc *desc; | ||
struct tsnep_rx_desc_wb *desc_wb; | ||
dma_addr_t desc_dma; | ||
|
||
u32 properties; | ||
|
||
struct sk_buff *skb; | ||
size_t len; | ||
DEFINE_DMA_UNMAP_ADDR(dma); | ||
}; | ||
|
||
struct tsnep_rx { | ||
struct tsnep_adapter *adapter; | ||
void __iomem *addr; | ||
|
||
void *page[TSNEP_RING_PAGE_COUNT]; | ||
dma_addr_t page_dma[TSNEP_RING_PAGE_COUNT]; | ||
|
||
struct tsnep_rx_entry entry[TSNEP_RING_SIZE]; | ||
int read; | ||
u32 owner_counter; | ||
int increment_owner_counter; | ||
|
||
u32 packets; | ||
u32 bytes; | ||
u32 dropped; | ||
u32 multicast; | ||
}; | ||
|
||
struct tsnep_queue { | ||
struct tsnep_adapter *adapter; | ||
|
||
struct tsnep_tx *tx; | ||
struct tsnep_rx *rx; | ||
|
||
struct napi_struct napi; | ||
|
||
u32 irq_mask; | ||
}; | ||
|
||
struct tsnep_adapter { | ||
struct net_device *netdev; | ||
u8 mac_address[ETH_ALEN]; | ||
struct mii_bus *mdiobus; | ||
bool suppress_preamble; | ||
phy_interface_t phy_mode; | ||
struct phy_device *phydev; | ||
int msg_enable; | ||
|
||
struct platform_device *pdev; | ||
struct device *dmadev; | ||
void __iomem *addr; | ||
unsigned long size; | ||
int irq; | ||
|
||
bool gate_control; | ||
/* gate control lock */ | ||
struct mutex gate_control_lock; | ||
bool gate_control_active; | ||
struct tsnep_gcl gcl[2]; | ||
int next_gcl; | ||
|
||
struct hwtstamp_config hwtstamp_config; | ||
struct ptp_clock *ptp_clock; | ||
struct ptp_clock_info ptp_clock_info; | ||
/* ptp clock lock */ | ||
spinlock_t ptp_lock; | ||
|
||
int num_tx_queues; | ||
struct tsnep_tx tx[TSNEP_MAX_QUEUES]; | ||
int num_rx_queues; | ||
struct tsnep_rx rx[TSNEP_MAX_QUEUES]; | ||
|
||
int num_queues; | ||
struct tsnep_queue queue[TSNEP_MAX_QUEUES]; | ||
}; | ||
|
||
extern const struct ethtool_ops tsnep_ethtool_ops; | ||
|
||
int tsnep_ptp_init(struct tsnep_adapter *adapter); | ||
void tsnep_ptp_cleanup(struct tsnep_adapter *adapter); | ||
int tsnep_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); | ||
|
||
int tsnep_tc_init(struct tsnep_adapter *adapter); | ||
void tsnep_tc_cleanup(struct tsnep_adapter *adapter); | ||
int tsnep_tc_setup(struct net_device *netdev, enum tc_setup_type type, | ||
void *type_data); | ||
|
||
#if IS_ENABLED(CONFIG_TSNEP_SELFTESTS) | ||
int tsnep_ethtool_get_test_count(void); | ||
void tsnep_ethtool_get_test_strings(u8 *data); | ||
void tsnep_ethtool_self_test(struct net_device *netdev, | ||
struct ethtool_test *eth_test, u64 *data); | ||
#else | ||
static inline int tsnep_ethtool_get_test_count(void) | ||
{ | ||
return -EOPNOTSUPP; | ||
} | ||
|
||
static inline void tsnep_ethtool_get_test_strings(u8 *data) | ||
{ | ||
/* not enabled */ | ||
} | ||
|
||
static inline void tsnep_ethtool_self_test(struct net_device *dev, | ||
struct ethtool_test *eth_test, | ||
u64 *data) | ||
{ | ||
/* not enabled */ | ||
} | ||
#endif /* CONFIG_TSNEP_SELFTESTS */ | ||
|
||
void tsnep_get_system_time(struct tsnep_adapter *adapter, u64 *time); | ||
|
||
#endif /* _TSNEP_H */ |
Oops, something went wrong.