ocelot.h 2.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/* SPDX-License-Identifier: (GPL-2.0 OR MIT) */
/*
 * Microsemi Ocelot Switch driver
 *
 * Copyright (c) 2017 Microsemi Corporation
 */

#ifndef _MSCC_OCELOT_H_
#define _MSCC_OCELOT_H_

#include <linux/bitops.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
14
#include <linux/net_tstamp.h>
15 16
#include <linux/phy.h>
#include <linux/phy/phy.h>
17
#include <linux/platform_device.h>
18
#include <linux/ptp_clock_kernel.h>
19 20
#include <linux/regmap.h>

21
#include <soc/mscc/ocelot_sys.h>
22
#include <soc/mscc/ocelot.h>
23 24 25 26 27
#include "ocelot_ana.h"
#include "ocelot_dev.h"
#include "ocelot_qsys.h"
#include "ocelot_rew.h"
#include "ocelot_qs.h"
28
#include "ocelot_tc.h"
29
#include "ocelot_ptp.h"
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44

#define PGID_AGGR    64
#define PGID_SRC     80

/* Reserved PGIDs */
#define PGID_CPU     (PGID_AGGR - 5)
#define PGID_UC      (PGID_AGGR - 4)
#define PGID_MC      (PGID_AGGR - 3)
#define PGID_MCIPV4  (PGID_AGGR - 2)
#define PGID_MCIPV6  (PGID_AGGR - 1)

#define OCELOT_BUFFER_CELL_SZ 60

#define OCELOT_STATS_CHECK_DELAY (2 * HZ)

45 46
#define OCELOT_PTP_QUEUE_SZ	128

47 48 49 50 51
struct frame_info {
	u32 len;
	u16 port;
	u16 vid;
	u8 tag_type;
52 53
	u16 rew_op;
	u32 timestamp;	/* rew_val */
54 55 56 57 58 59 60 61 62
};

struct ocelot_multicast {
	struct list_head list;
	unsigned char addr[ETH_ALEN];
	u16 vid;
	u16 ports;
};

63 64 65 66 67 68 69
struct ocelot_port_private {
	struct ocelot_port port;
	struct net_device *dev;
	struct phy_device *phy;
	u8 chip_port;

	u8 vlan_aware;
70 71 72

	phy_interface_t phy_mode;
	struct phy *serdes;
73 74

	struct ocelot_port_tc tc;
75 76 77 78 79 80
};

struct ocelot_skb {
	struct list_head head;
	struct sk_buff *skb;
	u8 id;
81 82 83 84 85 86 87 88
};

u32 ocelot_port_readl(struct ocelot_port *port, u32 reg);
void ocelot_port_writel(struct ocelot_port *port, u32 val, u32 reg);

#define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
#define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))

89
int ocelot_chip_init(struct ocelot *ocelot, const struct ocelot_ops *ops);
90 91 92 93
int ocelot_probe_port(struct ocelot *ocelot, u8 port,
		      void __iomem *regs,
		      struct phy_device *phy);

94 95 96 97
void ocelot_set_cpu_port(struct ocelot *ocelot, int cpu,
			 enum ocelot_tag_prefix injection,
			 enum ocelot_tag_prefix extraction);

98
extern struct notifier_block ocelot_netdevice_nb;
99
extern struct notifier_block ocelot_switchdev_nb;
100
extern struct notifier_block ocelot_switchdev_blocking_nb;
101

102 103
#define ocelot_field_write(ocelot, reg, val) regmap_field_write((ocelot)->regfields[(reg)], (val))
#define ocelot_field_read(ocelot, reg, val) regmap_field_read((ocelot)->regfields[(reg)], (val))
104

105
#endif