]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - drivers/net/ethernet/mscc/ocelot.h
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[mirror_ubuntu-jammy-kernel.git] / drivers / net / ethernet / mscc / ocelot.h
CommitLineData
a556c76a
AB
1/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
2/*
3 * Microsemi Ocelot Switch driver
4 *
5 * Copyright (c) 2017 Microsemi Corporation
6 */
7
8#ifndef _MSCC_OCELOT_H_
9#define _MSCC_OCELOT_H_
10
11#include <linux/bitops.h>
12#include <linux/etherdevice.h>
13#include <linux/if_vlan.h>
4e3b0468 14#include <linux/net_tstamp.h>
71e32a20
QS
15#include <linux/phy.h>
16#include <linux/phy/phy.h>
a556c76a
AB
17#include <linux/platform_device.h>
18#include <linux/regmap.h>
19
964ee5c8 20#include <soc/mscc/ocelot_qsys.h>
a030dfe1 21#include <soc/mscc/ocelot_sys.h>
964ee5c8
VO
22#include <soc/mscc/ocelot_dev.h>
23#include <soc/mscc/ocelot_ana.h>
2b49d128 24#include <soc/mscc/ocelot_ptp.h>
5e256365 25#include <soc/mscc/ocelot.h>
a556c76a 26#include "ocelot_rew.h"
a556c76a
AB
27#include "ocelot_qs.h"
28
a556c76a
AB
29#define OCELOT_BUFFER_CELL_SZ 60
30
31#define OCELOT_STATS_CHECK_DELAY (2 * HZ)
32
4e3b0468
AT
33#define OCELOT_PTP_QUEUE_SZ 128
34
9c90eea3
VO
35struct ocelot_port_tc {
36 bool block_shared;
37 unsigned long offload_cnt;
38
39 unsigned long police_id;
40};
41
004d44f6
VO
42struct ocelot_port_private {
43 struct ocelot_port port;
44 struct net_device *dev;
45 struct phy_device *phy;
46 u8 chip_port;
47
71e32a20 48 struct phy *serdes;
2c1d029a
JA
49
50 struct ocelot_port_tc tc;
4e3b0468
AT
51};
52
9c90eea3
VO
53struct ocelot_dump_ctx {
54 struct net_device *dev;
55 struct sk_buff *skb;
56 struct netlink_callback *cb;
57 int idx;
58};
59
60/* MAC table entry types.
61 * ENTRYTYPE_NORMAL is subject to aging.
62 * ENTRYTYPE_LOCKED is not subject to aging.
63 * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
64 * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
65 */
66enum macaccess_entry_type {
67 ENTRYTYPE_NORMAL = 0,
68 ENTRYTYPE_LOCKED,
69 ENTRYTYPE_MACv4,
70 ENTRYTYPE_MACv6,
71};
72
e5d1f896
VO
73/* A (PGID) port mask structure, encoding the 2^ocelot->num_phys_ports
74 * possibilities of egress port masks for L2 multicast traffic.
75 * For a switch with 9 user ports, there are 512 possible port masks, but the
76 * hardware only has 46 individual PGIDs that it can forward multicast traffic
77 * to. So we need a structure that maps the limited PGID indices to the port
78 * destinations requested by the user for L2 multicast.
79 */
80struct ocelot_pgid {
81 unsigned long ports;
82 int index;
83 refcount_t refcount;
84 struct list_head list;
85};
86
bb8d53fd
VO
87struct ocelot_multicast {
88 struct list_head list;
89 enum macaccess_entry_type entry_type;
90 unsigned char addr[ETH_ALEN];
91 u16 vid;
92 u16 ports;
e5d1f896 93 struct ocelot_pgid *pgid;
bb8d53fd
VO
94};
95
9c90eea3
VO
96int ocelot_port_fdb_do_dump(const unsigned char *addr, u16 vid,
97 bool is_static, void *data);
98int ocelot_mact_learn(struct ocelot *ocelot, int port,
99 const unsigned char mac[ETH_ALEN],
100 unsigned int vid, enum macaccess_entry_type type);
101int ocelot_mact_forget(struct ocelot *ocelot,
102 const unsigned char mac[ETH_ALEN], unsigned int vid);
319e4dd1
VO
103struct net_device *ocelot_port_to_netdev(struct ocelot *ocelot, int port);
104int ocelot_netdev_to_port(struct net_device *dev);
9c90eea3 105
a556c76a
AB
106u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
107void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);
108
91c724cf 109int ocelot_probe_port(struct ocelot *ocelot, int port, struct regmap *target,
a556c76a 110 struct phy_device *phy);
e0c16233 111void ocelot_release_port(struct ocelot_port *ocelot_port);
6c30384e
VO
112int ocelot_devlink_init(struct ocelot *ocelot);
113void ocelot_devlink_teardown(struct ocelot *ocelot);
114int ocelot_port_devlink_init(struct ocelot *ocelot, int port,
115 enum devlink_port_flavour flavour);
116void ocelot_port_devlink_teardown(struct ocelot *ocelot, int port);
a556c76a
AB
117
118extern struct notifier_block ocelot_netdevice_nb;
56da64bc 119extern struct notifier_block ocelot_switchdev_nb;
0e332c85 120extern struct notifier_block ocelot_switchdev_blocking_nb;
6c30384e 121extern const struct devlink_ops ocelot_devlink_ops;
a556c76a
AB
122
123#endif