Skip to content

Commit 7cb0847

Browse files
author
Paolo Abeni
committed
Merge branch 'add-support-of-hibmcge-ethernet-driver'
Jijie Shao says: ==================== Add support of HIBMCGE Ethernet Driver This patch set adds the support of Hisilicon BMC Gigabit Ethernet Driver. This patch set includes basic Rx/Tx functionality. It also includes the registration and interrupt codes. This work provides the initial support to the HIBMCGE and would incrementally add features or enhancements. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 90cb5f1 + f9a002a commit 7cb0847

File tree

17 files changed

+1737
-1
lines changed

17 files changed

+1737
-1
lines changed

MAINTAINERS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10278,6 +10278,12 @@ S: Maintained
1027810278
W: http://www.hisilicon.com
1027910279
F: drivers/net/ethernet/hisilicon/hns3/
1028010280

10281+
HISILICON NETWORK HIBMCGE DRIVER
10282+
M: Jijie Shao <[email protected]>
10283+
10284+
S: Maintained
10285+
F: drivers/net/ethernet/hisilicon/hibmcge/
10286+
1028110287
HISILICON NETWORK SUBSYSTEM DRIVER
1028210288
M: Jian Shen <[email protected]>
1028310289
M: Salil Mehta <[email protected]>

drivers/net/ethernet/hisilicon/Kconfig

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ config NET_VENDOR_HISILICON
77
bool "Hisilicon devices"
88
default y
99
depends on OF || ACPI
10-
depends on ARM || ARM64 || COMPILE_TEST
1110
help
1211
If you have a network (Ethernet) card belonging to this class, say Y.
1312

@@ -18,6 +17,8 @@ config NET_VENDOR_HISILICON
1817

1918
if NET_VENDOR_HISILICON
2019

20+
if ARM || ARM64 || COMPILE_TEST
21+
2122
config HIX5HD2_GMAC
2223
tristate "Hisilicon HIX5HD2 Family Network Device Support"
2324
select PHYLIB
@@ -141,4 +142,19 @@ config HNS3_ENET
141142

142143
endif #HNS3
143144

145+
endif # ARM || ARM64 || COMPILE_TEST
146+
147+
config HIBMCGE
148+
tristate "Hisilicon BMC Gigabit Ethernet Device Support"
149+
depends on PCI && PCI_MSI
150+
select PHYLIB
151+
select MOTORCOMM_PHY
152+
select REALTEK_PHY
153+
help
154+
If you wish to compile a kernel for a BMC with HIBMC-xx_gmac
155+
then you should answer Y to this. This makes this driver suitable for use
156+
on certain boards such as the HIBMC-210.
157+
158+
If you are unsure, say N.
159+
144160
endif # NET_VENDOR_HISILICON

drivers/net/ethernet/hisilicon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ obj-$(CONFIG_HNS_MDIO) += hns_mdio.o
99
obj-$(CONFIG_HNS) += hns/
1010
obj-$(CONFIG_HNS3) += hns3/
1111
obj-$(CONFIG_HISI_FEMAC) += hisi_femac.o
12+
obj-$(CONFIG_HIBMCGE) += hibmcge/
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: GPL-2.0+
2+
#
3+
# Makefile for the HISILICON BMC GE network device drivers.
4+
#
5+
6+
obj-$(CONFIG_HIBMCGE) += hibmcge.o
7+
8+
hibmcge-objs = hbg_main.o hbg_hw.o hbg_mdio.o hbg_irq.o hbg_txrx.o hbg_ethtool.o
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ */
2+
/* Copyright (c) 2024 Hisilicon Limited. */
3+
4+
#ifndef __HBG_COMMON_H
5+
#define __HBG_COMMON_H
6+
7+
#include <linux/netdevice.h>
8+
#include <linux/pci.h>
9+
#include "hbg_reg.h"
10+
11+
#define HBG_STATUS_DISABLE 0x0
12+
#define HBG_STATUS_ENABLE 0x1
13+
#define HBG_RX_SKIP1 0x00
14+
#define HBG_RX_SKIP2 0x01
15+
#define HBG_VECTOR_NUM 4
16+
#define HBG_PCU_CACHE_LINE_SIZE 32
17+
#define HBG_TX_TIMEOUT_BUF_LEN 1024
18+
#define HBG_RX_DESCR 0x01
19+
20+
#define HBG_PACKET_HEAD_SIZE ((HBG_RX_SKIP1 + HBG_RX_SKIP2 + \
21+
HBG_RX_DESCR) * HBG_PCU_CACHE_LINE_SIZE)
22+
23+
enum hbg_dir {
24+
HBG_DIR_TX = 1 << 0,
25+
HBG_DIR_RX = 1 << 1,
26+
HBG_DIR_TX_RX = HBG_DIR_TX | HBG_DIR_RX,
27+
};
28+
29+
enum hbg_tx_state {
30+
HBG_TX_STATE_COMPLETE = 0, /* clear state, must fix to 0 */
31+
HBG_TX_STATE_START,
32+
};
33+
34+
enum hbg_nic_state {
35+
HBG_NIC_STATE_EVENT_HANDLING = 0,
36+
};
37+
38+
struct hbg_buffer {
39+
u32 state;
40+
dma_addr_t state_dma;
41+
42+
struct sk_buff *skb;
43+
dma_addr_t skb_dma;
44+
u32 skb_len;
45+
46+
enum hbg_dir dir;
47+
struct hbg_ring *ring;
48+
struct hbg_priv *priv;
49+
};
50+
51+
struct hbg_ring {
52+
struct hbg_buffer *queue;
53+
dma_addr_t queue_dma;
54+
55+
union {
56+
u32 head;
57+
u32 ntc;
58+
};
59+
union {
60+
u32 tail;
61+
u32 ntu;
62+
};
63+
u32 len;
64+
65+
enum hbg_dir dir;
66+
struct hbg_priv *priv;
67+
struct napi_struct napi;
68+
char *tout_log_buf; /* tx timeout log buffer */
69+
};
70+
71+
enum hbg_hw_event_type {
72+
HBG_HW_EVENT_NONE = 0,
73+
HBG_HW_EVENT_INIT, /* driver is loading */
74+
HBG_HW_EVENT_RESET,
75+
};
76+
77+
struct hbg_dev_specs {
78+
u32 mac_id;
79+
struct sockaddr mac_addr;
80+
u32 phy_addr;
81+
u32 mdio_frequency;
82+
u32 rx_fifo_num;
83+
u32 tx_fifo_num;
84+
u32 vlan_layers;
85+
u32 max_mtu;
86+
u32 min_mtu;
87+
88+
u32 max_frame_len;
89+
u32 rx_buf_size;
90+
};
91+
92+
struct hbg_irq_info {
93+
const char *name;
94+
u32 mask;
95+
bool re_enable;
96+
bool need_print;
97+
u64 count;
98+
99+
void (*irq_handle)(struct hbg_priv *priv, struct hbg_irq_info *info);
100+
};
101+
102+
struct hbg_vector {
103+
char name[HBG_VECTOR_NUM][32];
104+
struct hbg_irq_info *info_array;
105+
u32 info_array_len;
106+
};
107+
108+
struct hbg_mac {
109+
struct mii_bus *mdio_bus;
110+
struct phy_device *phydev;
111+
u8 phy_addr;
112+
113+
u32 speed;
114+
u32 duplex;
115+
u32 autoneg;
116+
u32 link_status;
117+
};
118+
119+
struct hbg_priv {
120+
struct net_device *netdev;
121+
struct pci_dev *pdev;
122+
u8 __iomem *io_base;
123+
struct hbg_dev_specs dev_specs;
124+
unsigned long state;
125+
struct hbg_mac mac;
126+
struct hbg_vector vectors;
127+
struct hbg_ring tx_ring;
128+
struct hbg_ring rx_ring;
129+
};
130+
131+
#endif
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: GPL-2.0+
2+
// Copyright (c) 2024 Hisilicon Limited.
3+
4+
#include <linux/ethtool.h>
5+
#include <linux/phy.h>
6+
#include "hbg_ethtool.h"
7+
8+
static const struct ethtool_ops hbg_ethtool_ops = {
9+
.get_link = ethtool_op_get_link,
10+
.get_link_ksettings = phy_ethtool_get_link_ksettings,
11+
.set_link_ksettings = phy_ethtool_set_link_ksettings,
12+
};
13+
14+
void hbg_ethtool_set_ops(struct net_device *netdev)
15+
{
16+
netdev->ethtool_ops = &hbg_ethtool_ops;
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* SPDX-License-Identifier: GPL-2.0+ */
2+
/* Copyright (c) 2024 Hisilicon Limited. */
3+
4+
#ifndef __HBG_ETHTOOL_H
5+
#define __HBG_ETHTOOL_H
6+
7+
#include <linux/netdevice.h>
8+
9+
void hbg_ethtool_set_ops(struct net_device *netdev);
10+
11+
#endif

0 commit comments

Comments
 (0)