Linux Audio

Check our new training course

Embedded Linux training

Mar 10-20, 2025, special US time zones
Register
Loading...
v3.15
 
  1/*
  2 * Texas Instruments 3-Port Ethernet Switch Address Lookup Engine APIs
  3 *
  4 * Copyright (C) 2012 Texas Instruments
  5 *
  6 * This program is free software; you can redistribute it and/or
  7 * modify it under the terms of the GNU General Public License as
  8 * published by the Free Software Foundation version 2.
  9 *
 10 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
 11 * kind, whether express or implied; without even the implied warranty
 12 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13 * GNU General Public License for more details.
 14 */
 15#ifndef __TI_CPSW_ALE_H__
 16#define __TI_CPSW_ALE_H__
 17
 18struct cpsw_ale_params {
 19	struct device		*dev;
 20	void __iomem		*ale_regs;
 21	unsigned long		ale_ageout;	/* in secs */
 22	unsigned long		ale_entries;
 23	unsigned long		ale_ports;
 
 
 
 
 
 
 
 
 
 
 
 
 24};
 25
 
 
 26struct cpsw_ale {
 27	struct cpsw_ale_params	params;
 28	struct timer_list	timer;
 29	unsigned long		ageout;
 
 
 
 
 
 
 
 
 30};
 31
 32enum cpsw_ale_control {
 33	/* global */
 34	ALE_ENABLE,
 35	ALE_CLEAR,
 36	ALE_AGEOUT,
 37	ALE_P0_UNI_FLOOD,
 38	ALE_VLAN_NOLEARN,
 39	ALE_NO_PORT_VLAN,
 40	ALE_OUI_DENY,
 41	ALE_BYPASS,
 42	ALE_RATE_LIMIT_TX,
 43	ALE_VLAN_AWARE,
 44	ALE_AUTH_ENABLE,
 45	ALE_RATE_LIMIT,
 46	/* port controls */
 47	ALE_PORT_STATE,
 48	ALE_PORT_DROP_UNTAGGED,
 49	ALE_PORT_DROP_UNKNOWN_VLAN,
 50	ALE_PORT_NOLEARN,
 51	ALE_PORT_NO_SA_UPDATE,
 52	ALE_PORT_UNKNOWN_VLAN_MEMBER,
 53	ALE_PORT_UNKNOWN_MCAST_FLOOD,
 54	ALE_PORT_UNKNOWN_REG_MCAST_FLOOD,
 55	ALE_PORT_UNTAGGED_EGRESS,
 
 
 56	ALE_PORT_BCAST_LIMIT,
 57	ALE_PORT_MCAST_LIMIT,
 
 
 58	ALE_NUM_CONTROLS,
 59};
 60
 61enum cpsw_ale_port_state {
 62	ALE_PORT_STATE_DISABLE	= 0x00,
 63	ALE_PORT_STATE_BLOCK	= 0x01,
 64	ALE_PORT_STATE_LEARN	= 0x02,
 65	ALE_PORT_STATE_FORWARD	= 0x03,
 66};
 67
 68/* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */
 69#define ALE_SECURE			BIT(0)
 70#define ALE_BLOCKED			BIT(1)
 71#define ALE_SUPER			BIT(2)
 72#define ALE_VLAN			BIT(3)
 73
 74#define ALE_PORT_HOST			BIT(0)
 75#define ALE_PORT_1			BIT(1)
 76#define ALE_PORT_2			BIT(2)
 77
 78#define ALE_MCAST_FWD			0
 79#define ALE_MCAST_BLOCK_LEARN_FWD	1
 80#define ALE_MCAST_FWD_LEARN		2
 81#define ALE_MCAST_FWD_2			3
 82
 
 
 
 83struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
 84int cpsw_ale_destroy(struct cpsw_ale *ale);
 85
 86void cpsw_ale_start(struct cpsw_ale *ale);
 87void cpsw_ale_stop(struct cpsw_ale *ale);
 88
 89int cpsw_ale_set_ageout(struct cpsw_ale *ale, int ageout);
 90int cpsw_ale_flush(struct cpsw_ale *ale, int port_mask);
 91int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask);
 92int cpsw_ale_add_ucast(struct cpsw_ale *ale, u8 *addr, int port,
 93		       int flags, u16 vid);
 94int cpsw_ale_del_ucast(struct cpsw_ale *ale, u8 *addr, int port,
 95		       int flags, u16 vid);
 96int cpsw_ale_add_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
 97		       int flags, u16 vid, int mcast_state);
 98int cpsw_ale_del_mcast(struct cpsw_ale *ale, u8 *addr, int port_mask,
 99		       int flags, u16 vid);
100int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
101			int reg_mcast, int unreg_mcast);
102int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
 
 
 
103
104int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
105int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
106			 int control, int value);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
108#endif
v6.9.4
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * Texas Instruments N-Port Ethernet Switch Address Lookup Engine APIs
  4 *
  5 * Copyright (C) 2012 Texas Instruments
  6 *
 
 
 
 
 
 
 
 
  7 */
  8#ifndef __TI_CPSW_ALE_H__
  9#define __TI_CPSW_ALE_H__
 10
 11struct cpsw_ale_params {
 12	struct device		*dev;
 13	void __iomem		*ale_regs;
 14	unsigned long		ale_ageout;	/* in secs */
 15	unsigned long		ale_entries;
 16	unsigned long		ale_ports;
 17	/* NU Switch has specific handling as number of bits in ALE entries
 18	 * are different than other versions of ALE. Also there are specific
 19	 * registers for unknown vlan specific fields. So use nu_switch_ale
 20	 * to identify this hardware.
 21	 */
 22	bool			nu_switch_ale;
 23	/* mask bit used in NU Switch ALE is 3 bits instead of 8 bits. So
 24	 * pass it from caller.
 25	 */
 26	u32			major_ver_mask;
 27	const char		*dev_id;
 28	unsigned long		bus_freq;
 29};
 30
 31struct ale_entry_fld;
 32
 33struct cpsw_ale {
 34	struct cpsw_ale_params	params;
 35	struct timer_list	timer;
 36	unsigned long		ageout;
 37	u32			version;
 38	u32			features;
 39	/* These bits are different on NetCP NU Switch ALE */
 40	u32			port_mask_bits;
 41	u32			port_num_bits;
 42	u32			vlan_field_bits;
 43	unsigned long		*p0_untag_vid_mask;
 44	const struct ale_entry_fld *vlan_entry_tbl;
 45};
 46
 47enum cpsw_ale_control {
 48	/* global */
 49	ALE_ENABLE,
 50	ALE_CLEAR,
 51	ALE_AGEOUT,
 52	ALE_P0_UNI_FLOOD,
 53	ALE_VLAN_NOLEARN,
 54	ALE_NO_PORT_VLAN,
 55	ALE_OUI_DENY,
 56	ALE_BYPASS,
 57	ALE_RATE_LIMIT_TX,
 58	ALE_VLAN_AWARE,
 59	ALE_AUTH_ENABLE,
 60	ALE_RATE_LIMIT,
 61	/* port controls */
 62	ALE_PORT_STATE,
 63	ALE_PORT_DROP_UNTAGGED,
 64	ALE_PORT_DROP_UNKNOWN_VLAN,
 65	ALE_PORT_NOLEARN,
 66	ALE_PORT_NO_SA_UPDATE,
 67	ALE_PORT_UNKNOWN_VLAN_MEMBER,
 68	ALE_PORT_UNKNOWN_MCAST_FLOOD,
 69	ALE_PORT_UNKNOWN_REG_MCAST_FLOOD,
 70	ALE_PORT_UNTAGGED_EGRESS,
 71	ALE_PORT_MACONLY,
 72	ALE_PORT_MACONLY_CAF,
 73	ALE_PORT_BCAST_LIMIT,
 74	ALE_PORT_MCAST_LIMIT,
 75	ALE_DEFAULT_THREAD_ID,
 76	ALE_DEFAULT_THREAD_ENABLE,
 77	ALE_NUM_CONTROLS,
 78};
 79
 80enum cpsw_ale_port_state {
 81	ALE_PORT_STATE_DISABLE	= 0x00,
 82	ALE_PORT_STATE_BLOCK	= 0x01,
 83	ALE_PORT_STATE_LEARN	= 0x02,
 84	ALE_PORT_STATE_FORWARD	= 0x03,
 85};
 86
 87/* ALE unicast entry flags - passed into cpsw_ale_add_ucast() */
 88#define ALE_SECURE			BIT(0)
 89#define ALE_BLOCKED			BIT(1)
 90#define ALE_SUPER			BIT(2)
 91#define ALE_VLAN			BIT(3)
 92
 93#define ALE_PORT_HOST			BIT(0)
 94#define ALE_PORT_1			BIT(1)
 95#define ALE_PORT_2			BIT(2)
 96
 97#define ALE_MCAST_FWD			0
 98#define ALE_MCAST_BLOCK_LEARN_FWD	1
 99#define ALE_MCAST_FWD_LEARN		2
100#define ALE_MCAST_FWD_2			3
101
102#define ALE_ENTRY_BITS		68
103#define ALE_ENTRY_WORDS	DIV_ROUND_UP(ALE_ENTRY_BITS, 32)
104
105struct cpsw_ale *cpsw_ale_create(struct cpsw_ale_params *params);
 
106
107void cpsw_ale_start(struct cpsw_ale *ale);
108void cpsw_ale_stop(struct cpsw_ale *ale);
109
110int cpsw_ale_flush_multicast(struct cpsw_ale *ale, int port_mask, int vid);
111int cpsw_ale_add_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
 
 
112		       int flags, u16 vid);
113int cpsw_ale_del_ucast(struct cpsw_ale *ale, const u8 *addr, int port,
114		       int flags, u16 vid);
115int cpsw_ale_add_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
116		       int flags, u16 vid, int mcast_state);
117int cpsw_ale_del_mcast(struct cpsw_ale *ale, const u8 *addr, int port_mask,
118		       int flags, u16 vid);
119int cpsw_ale_add_vlan(struct cpsw_ale *ale, u16 vid, int port, int untag,
120			int reg_mcast, int unreg_mcast);
121int cpsw_ale_del_vlan(struct cpsw_ale *ale, u16 vid, int port);
122void cpsw_ale_set_allmulti(struct cpsw_ale *ale, int allmulti, int port);
123int cpsw_ale_rx_ratelimit_bc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps);
124int cpsw_ale_rx_ratelimit_mc(struct cpsw_ale *ale, int port, unsigned int ratelimit_pps);
125
126int cpsw_ale_control_get(struct cpsw_ale *ale, int port, int control);
127int cpsw_ale_control_set(struct cpsw_ale *ale, int port,
128			 int control, int value);
129void cpsw_ale_dump(struct cpsw_ale *ale, u32 *data);
130void cpsw_ale_restore(struct cpsw_ale *ale, u32 *data);
131u32 cpsw_ale_get_num_entries(struct cpsw_ale *ale);
132
133static inline int cpsw_ale_get_vlan_p0_untag(struct cpsw_ale *ale, u16 vid)
134{
135	return test_bit(vid, ale->p0_untag_vid_mask);
136}
137
138int cpsw_ale_vlan_add_modify(struct cpsw_ale *ale, u16 vid, int port_mask,
139			     int untag_mask, int reg_mcast, int unreg_mcast);
140int cpsw_ale_vlan_del_modify(struct cpsw_ale *ale, u16 vid, int port_mask);
141void cpsw_ale_set_unreg_mcast(struct cpsw_ale *ale, int unreg_mcast_mask,
142			      bool add);
143
144#endif