Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v5.2-rc5 172 lines 4.8 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 2 * 3 * Microchip KSZ series switch common definitions 4 * 5 * Copyright (C) 2017-2019 Microchip Technology Inc. 6 */ 7 8#ifndef __KSZ_PRIV_H 9#define __KSZ_PRIV_H 10 11#include <linux/kernel.h> 12#include <linux/mutex.h> 13#include <linux/phy.h> 14#include <linux/etherdevice.h> 15#include <net/dsa.h> 16 17struct ksz_io_ops; 18 19struct vlan_table { 20 u32 table[3]; 21}; 22 23struct ksz_port_mib { 24 struct mutex cnt_mutex; /* structure access */ 25 u8 cnt_ptr; 26 u64 *counters; 27}; 28 29struct ksz_port { 30 u16 member; 31 u16 vid_member; 32 int stp_state; 33 struct phy_device phydev; 34 35 u32 on:1; /* port is not disabled by hardware */ 36 u32 phy:1; /* port has a PHY */ 37 u32 fiber:1; /* port is fiber */ 38 u32 sgmii:1; /* port is SGMII */ 39 u32 force:1; 40 u32 read:1; /* read MIB counters in background */ 41 u32 freeze:1; /* MIB counter freeze is enabled */ 42 43 struct ksz_port_mib mib; 44}; 45 46struct ksz_device { 47 struct dsa_switch *ds; 48 struct ksz_platform_data *pdata; 49 const char *name; 50 51 struct mutex dev_mutex; /* device access */ 52 struct mutex reg_mutex; /* register access */ 53 struct mutex stats_mutex; /* status access */ 54 struct mutex alu_mutex; /* ALU access */ 55 struct mutex vlan_mutex; /* vlan access */ 56 const struct ksz_io_ops *ops; 57 const struct ksz_dev_ops *dev_ops; 58 59 struct device *dev; 60 61 void *priv; 62 63 struct gpio_desc *reset_gpio; /* Optional reset GPIO */ 64 65 /* chip specific data */ 66 u32 chip_id; 67 int num_vlans; 68 int num_alus; 69 int num_statics; 70 int cpu_port; /* port connected to CPU */ 71 int cpu_ports; /* port bitmap can be cpu port */ 72 int phy_port_cnt; 73 int port_cnt; 74 int reg_mib_cnt; 75 int mib_cnt; 76 int mib_port_cnt; 77 int last_port; /* ports after that not used */ 78 phy_interface_t interface; 79 u32 regs_size; 80 81 struct vlan_table *vlan_cache; 82 83 u8 *txbuf; 84 85 struct ksz_port *ports; 86 struct timer_list mib_read_timer; 87 struct work_struct mib_read; 88 unsigned long mib_read_interval; 89 u16 br_member; 90 u16 member; 91 u16 live_ports; 92 u16 on_ports; /* ports enabled by DSA */ 93 u16 rx_ports; 94 u16 tx_ports; 95 u16 mirror_rx; 96 u16 mirror_tx; 97 u32 features; /* chip specific features */ 98 u32 overrides; /* chip functions set by user */ 99 u16 host_mask; 100 u16 port_mask; 101}; 102 103struct ksz_io_ops { 104 int (*read8)(struct ksz_device *dev, u32 reg, u8 *value); 105 int (*read16)(struct ksz_device *dev, u32 reg, u16 *value); 106 int (*read24)(struct ksz_device *dev, u32 reg, u32 *value); 107 int (*read32)(struct ksz_device *dev, u32 reg, u32 *value); 108 int (*write8)(struct ksz_device *dev, u32 reg, u8 value); 109 int (*write16)(struct ksz_device *dev, u32 reg, u16 value); 110 int (*write24)(struct ksz_device *dev, u32 reg, u32 value); 111 int (*write32)(struct ksz_device *dev, u32 reg, u32 value); 112 int (*get)(struct ksz_device *dev, u32 reg, void *data, size_t len); 113 int (*set)(struct ksz_device *dev, u32 reg, void *data, size_t len); 114}; 115 116struct alu_struct { 117 /* entry 1 */ 118 u8 is_static:1; 119 u8 is_src_filter:1; 120 u8 is_dst_filter:1; 121 u8 prio_age:3; 122 u32 _reserv_0_1:23; 123 u8 mstp:3; 124 /* entry 2 */ 125 u8 is_override:1; 126 u8 is_use_fid:1; 127 u32 _reserv_1_1:23; 128 u8 port_forward:7; 129 /* entry 3 & 4*/ 130 u32 _reserv_2_1:9; 131 u8 fid:7; 132 u8 mac[ETH_ALEN]; 133}; 134 135struct ksz_dev_ops { 136 u32 (*get_port_addr)(int port, int offset); 137 void (*cfg_port_member)(struct ksz_device *dev, int port, u8 member); 138 void (*flush_dyn_mac_table)(struct ksz_device *dev, int port); 139 void (*phy_setup)(struct ksz_device *dev, int port, 140 struct phy_device *phy); 141 void (*port_cleanup)(struct ksz_device *dev, int port); 142 void (*port_setup)(struct ksz_device *dev, int port, bool cpu_port); 143 void (*r_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 *val); 144 void (*w_phy)(struct ksz_device *dev, u16 phy, u16 reg, u16 val); 145 int (*r_dyn_mac_table)(struct ksz_device *dev, u16 addr, u8 *mac_addr, 146 u8 *fid, u8 *src_port, u8 *timestamp, 147 u16 *entries); 148 int (*r_sta_mac_table)(struct ksz_device *dev, u16 addr, 149 struct alu_struct *alu); 150 void (*w_sta_mac_table)(struct ksz_device *dev, u16 addr, 151 struct alu_struct *alu); 152 void (*r_mib_cnt)(struct ksz_device *dev, int port, u16 addr, 153 u64 *cnt); 154 void (*r_mib_pkt)(struct ksz_device *dev, int port, u16 addr, 155 u64 *dropped, u64 *cnt); 156 void (*freeze_mib)(struct ksz_device *dev, int port, bool freeze); 157 void (*port_init_cnt)(struct ksz_device *dev, int port); 158 int (*shutdown)(struct ksz_device *dev); 159 int (*detect)(struct ksz_device *dev); 160 int (*init)(struct ksz_device *dev); 161 void (*exit)(struct ksz_device *dev); 162}; 163 164struct ksz_device *ksz_switch_alloc(struct device *base, 165 const struct ksz_io_ops *ops, void *priv); 166int ksz_switch_register(struct ksz_device *dev, 167 const struct ksz_dev_ops *ops); 168void ksz_switch_remove(struct ksz_device *dev); 169 170int ksz9477_switch_register(struct ksz_device *dev); 171 172#endif