• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 
3 #ifndef __LAN966X_MAIN_H__
4 #define __LAN966X_MAIN_H__
5 
6 #include <linux/etherdevice.h>
7 #include <linux/if_vlan.h>
8 #include <linux/jiffies.h>
9 #include <linux/phy.h>
10 #include <linux/phylink.h>
11 #include <linux/ptp_clock_kernel.h>
12 #include <net/pkt_cls.h>
13 #include <net/pkt_sched.h>
14 #include <net/switchdev.h>
15 
16 #include "lan966x_regs.h"
17 #include "lan966x_ifh.h"
18 
19 #define TABLE_UPDATE_SLEEP_US		10
20 #define TABLE_UPDATE_TIMEOUT_US		100000
21 
22 #define READL_SLEEP_US			10
23 #define READL_TIMEOUT_US		100000000
24 
25 #define LAN966X_BUFFER_CELL_SZ		64
26 #define LAN966X_BUFFER_MEMORY		(160 * 1024)
27 #define LAN966X_BUFFER_MIN_SZ		60
28 
29 #define LAN966X_HW_MTU(mtu)		((mtu) + ETH_HLEN + ETH_FCS_LEN)
30 
31 #define PGID_AGGR			64
32 #define PGID_SRC			80
33 #define PGID_ENTRIES			89
34 
35 #define UNAWARE_PVID			0
36 #define HOST_PVID			4095
37 
38 /* Reserved amount for (SRC, PRIO) at index 8*SRC + PRIO */
39 #define QSYS_Q_RSRV			95
40 
41 #define NUM_PHYS_PORTS			8
42 #define CPU_PORT			8
43 #define NUM_PRIO_QUEUES			8
44 
45 /* Reserved PGIDs */
46 #define PGID_CPU			(PGID_AGGR - 6)
47 #define PGID_UC				(PGID_AGGR - 5)
48 #define PGID_BC				(PGID_AGGR - 4)
49 #define PGID_MC				(PGID_AGGR - 3)
50 #define PGID_MCIPV4			(PGID_AGGR - 2)
51 #define PGID_MCIPV6			(PGID_AGGR - 1)
52 
53 /* Non-reserved PGIDs, used for general purpose */
54 #define PGID_GP_START			(CPU_PORT + 1)
55 #define PGID_GP_END			PGID_CPU
56 
57 #define LAN966X_SPEED_NONE		0
58 #define LAN966X_SPEED_2500		1
59 #define LAN966X_SPEED_1000		1
60 #define LAN966X_SPEED_100		2
61 #define LAN966X_SPEED_10		3
62 
63 #define LAN966X_PHC_COUNT		3
64 #define LAN966X_PHC_PORT		0
65 #define LAN966X_PHC_PINS_NUM		7
66 
67 #define IFH_REW_OP_NOOP			0x0
68 #define IFH_REW_OP_ONE_STEP_PTP		0x3
69 #define IFH_REW_OP_TWO_STEP_PTP		0x4
70 
71 #define FDMA_RX_DCB_MAX_DBS		1
72 #define FDMA_TX_DCB_MAX_DBS		1
73 #define FDMA_DCB_INFO_DATAL(x)		((x) & GENMASK(15, 0))
74 
75 #define FDMA_DCB_STATUS_BLOCKL(x)	((x) & GENMASK(15, 0))
76 #define FDMA_DCB_STATUS_SOF		BIT(16)
77 #define FDMA_DCB_STATUS_EOF		BIT(17)
78 #define FDMA_DCB_STATUS_INTR		BIT(18)
79 #define FDMA_DCB_STATUS_DONE		BIT(19)
80 #define FDMA_DCB_STATUS_BLOCKO(x)	(((x) << 20) & GENMASK(31, 20))
81 #define FDMA_DCB_INVALID_DATA		0x1
82 
83 #define FDMA_XTR_CHANNEL		6
84 #define FDMA_INJ_CHANNEL		0
85 #define FDMA_DCB_MAX			512
86 
87 #define SE_IDX_QUEUE			0  /* 0-79 : Queue scheduler elements */
88 #define SE_IDX_PORT			80 /* 80-89 : Port schedular elements */
89 
90 /* MAC table entry types.
91  * ENTRYTYPE_NORMAL is subject to aging.
92  * ENTRYTYPE_LOCKED is not subject to aging.
93  * ENTRYTYPE_MACv4 is not subject to aging. For IPv4 multicast.
94  * ENTRYTYPE_MACv6 is not subject to aging. For IPv6 multicast.
95  */
96 enum macaccess_entry_type {
97 	ENTRYTYPE_NORMAL = 0,
98 	ENTRYTYPE_LOCKED,
99 	ENTRYTYPE_MACV4,
100 	ENTRYTYPE_MACV6,
101 };
102 
103 struct lan966x_port;
104 
105 struct lan966x_db {
106 	u64 dataptr;
107 	u64 status;
108 };
109 
110 struct lan966x_rx_dcb {
111 	u64 nextptr;
112 	u64 info;
113 	struct lan966x_db db[FDMA_RX_DCB_MAX_DBS];
114 };
115 
116 struct lan966x_tx_dcb {
117 	u64 nextptr;
118 	u64 info;
119 	struct lan966x_db db[FDMA_TX_DCB_MAX_DBS];
120 };
121 
122 struct lan966x_rx {
123 	struct lan966x *lan966x;
124 
125 	/* Pointer to the array of hardware dcbs. */
126 	struct lan966x_rx_dcb *dcbs;
127 
128 	/* Pointer to the last address in the dcbs. */
129 	struct lan966x_rx_dcb *last_entry;
130 
131 	/* For each DB, there is a page */
132 	struct page *page[FDMA_DCB_MAX][FDMA_RX_DCB_MAX_DBS];
133 
134 	/* Represents the db_index, it can have a value between 0 and
135 	 * FDMA_RX_DCB_MAX_DBS, once it reaches the value of FDMA_RX_DCB_MAX_DBS
136 	 * it means that the DCB can be reused.
137 	 */
138 	int db_index;
139 
140 	/* Represents the index in the dcbs. It has a value between 0 and
141 	 * FDMA_DCB_MAX
142 	 */
143 	int dcb_index;
144 
145 	/* Represents the dma address to the dcbs array */
146 	dma_addr_t dma;
147 
148 	/* Represents the page order that is used to allocate the pages for the
149 	 * RX buffers. This value is calculated based on max MTU of the devices.
150 	 */
151 	u8 page_order;
152 
153 	u8 channel_id;
154 };
155 
156 struct lan966x_tx_dcb_buf {
157 	struct net_device *dev;
158 	struct sk_buff *skb;
159 	dma_addr_t dma_addr;
160 	bool used;
161 	bool ptp;
162 };
163 
164 struct lan966x_tx {
165 	struct lan966x *lan966x;
166 
167 	/* Pointer to the dcb list */
168 	struct lan966x_tx_dcb *dcbs;
169 	u16 last_in_use;
170 
171 	/* Represents the DMA address to the first entry of the dcb entries. */
172 	dma_addr_t dma;
173 
174 	/* Array of dcbs that are given to the HW */
175 	struct lan966x_tx_dcb_buf *dcbs_buf;
176 
177 	u8 channel_id;
178 
179 	bool activated;
180 };
181 
182 struct lan966x_stat_layout {
183 	u32 offset;
184 	char name[ETH_GSTRING_LEN];
185 };
186 
187 struct lan966x_phc {
188 	struct ptp_clock *clock;
189 	struct ptp_clock_info info;
190 	struct ptp_pin_desc pins[LAN966X_PHC_PINS_NUM];
191 	struct hwtstamp_config hwtstamp_config;
192 	struct lan966x *lan966x;
193 	u8 index;
194 };
195 
196 struct lan966x_skb_cb {
197 	u8 rew_op;
198 	u16 ts_id;
199 	unsigned long jiffies;
200 };
201 
202 #define LAN966X_PTP_TIMEOUT		msecs_to_jiffies(10)
203 #define LAN966X_SKB_CB(skb) \
204 	((struct lan966x_skb_cb *)((skb)->cb))
205 
206 struct lan966x {
207 	struct device *dev;
208 
209 	u8 num_phys_ports;
210 	struct lan966x_port **ports;
211 
212 	void __iomem *regs[NUM_TARGETS];
213 
214 	int shared_queue_sz;
215 
216 	u8 base_mac[ETH_ALEN];
217 
218 	spinlock_t tx_lock; /* lock for frame transmition */
219 
220 	struct net_device *bridge;
221 	u16 bridge_mask;
222 	u16 bridge_fwd_mask;
223 
224 	struct list_head mac_entries;
225 	spinlock_t mac_lock; /* lock for mac_entries list */
226 
227 	u16 vlan_mask[VLAN_N_VID];
228 	DECLARE_BITMAP(cpu_vlan_mask, VLAN_N_VID);
229 
230 	/* stats */
231 	const struct lan966x_stat_layout *stats_layout;
232 	u32 num_stats;
233 
234 	/* workqueue for reading stats */
235 	struct mutex stats_lock;
236 	u64 *stats;
237 	struct delayed_work stats_work;
238 	struct workqueue_struct *stats_queue;
239 
240 	/* interrupts */
241 	int xtr_irq;
242 	int ana_irq;
243 	int ptp_irq;
244 	int fdma_irq;
245 	int ptp_ext_irq;
246 
247 	/* worqueue for fdb */
248 	struct workqueue_struct *fdb_work;
249 	struct list_head fdb_entries;
250 
251 	/* mdb */
252 	struct list_head mdb_entries;
253 	struct list_head pgid_entries;
254 
255 	/* ptp */
256 	bool ptp;
257 	struct lan966x_phc phc[LAN966X_PHC_COUNT];
258 	spinlock_t ptp_clock_lock; /* lock for phc */
259 	spinlock_t ptp_ts_id_lock; /* lock for ts_id */
260 	struct mutex ptp_lock; /* lock for ptp interface state */
261 	u16 ptp_skbs;
262 
263 	/* fdma */
264 	bool fdma;
265 	struct net_device *fdma_ndev;
266 	struct lan966x_rx rx;
267 	struct lan966x_tx tx;
268 	struct napi_struct napi;
269 
270 	/* Mirror */
271 	struct lan966x_port *mirror_monitor;
272 	u32 mirror_mask[2];
273 	u32 mirror_count;
274 };
275 
276 struct lan966x_port_config {
277 	phy_interface_t portmode;
278 	const unsigned long *advertising;
279 	int speed;
280 	int duplex;
281 	u32 pause;
282 	bool inband;
283 	bool autoneg;
284 };
285 
286 struct lan966x_port_tc {
287 	bool ingress_shared_block;
288 	unsigned long police_id;
289 	unsigned long ingress_mirror_id;
290 	unsigned long egress_mirror_id;
291 	struct flow_stats police_stat;
292 	struct flow_stats mirror_stat;
293 };
294 
295 struct lan966x_port {
296 	struct net_device *dev;
297 	struct lan966x *lan966x;
298 
299 	u8 chip_port;
300 	u16 pvid;
301 	u16 vid;
302 	bool vlan_aware;
303 
304 	bool learn_ena;
305 	bool mcast_ena;
306 
307 	struct phylink_config phylink_config;
308 	struct phylink_pcs phylink_pcs;
309 	struct lan966x_port_config config;
310 	struct phylink *phylink;
311 	struct phy *serdes;
312 	struct fwnode_handle *fwnode;
313 
314 	u8 ptp_cmd;
315 	u16 ts_id;
316 	struct sk_buff_head tx_skbs;
317 
318 	struct net_device *bond;
319 	bool lag_tx_active;
320 	enum netdev_lag_hash hash_type;
321 
322 	struct lan966x_port_tc tc;
323 };
324 
325 extern const struct phylink_mac_ops lan966x_phylink_mac_ops;
326 extern const struct phylink_pcs_ops lan966x_phylink_pcs_ops;
327 extern const struct ethtool_ops lan966x_ethtool_ops;
328 extern struct notifier_block lan966x_switchdev_nb __read_mostly;
329 extern struct notifier_block lan966x_switchdev_blocking_nb __read_mostly;
330 
331 bool lan966x_netdevice_check(const struct net_device *dev);
332 
333 void lan966x_register_notifier_blocks(void);
334 void lan966x_unregister_notifier_blocks(void);
335 
336 bool lan966x_hw_offload(struct lan966x *lan966x, u32 port, struct sk_buff *skb);
337 
338 void lan966x_ifh_get_src_port(void *ifh, u64 *src_port);
339 void lan966x_ifh_get_timestamp(void *ifh, u64 *timestamp);
340 
341 void lan966x_stats_get(struct net_device *dev,
342 		       struct rtnl_link_stats64 *stats);
343 int lan966x_stats_init(struct lan966x *lan966x);
344 
345 void lan966x_port_config_down(struct lan966x_port *port);
346 void lan966x_port_config_up(struct lan966x_port *port);
347 void lan966x_port_status_get(struct lan966x_port *port,
348 			     struct phylink_link_state *state);
349 int lan966x_port_pcs_set(struct lan966x_port *port,
350 			 struct lan966x_port_config *config);
351 void lan966x_port_init(struct lan966x_port *port);
352 
353 int lan966x_mac_ip_learn(struct lan966x *lan966x,
354 			 bool cpu_copy,
355 			 const unsigned char mac[ETH_ALEN],
356 			 unsigned int vid,
357 			 enum macaccess_entry_type type);
358 int lan966x_mac_learn(struct lan966x *lan966x, int port,
359 		      const unsigned char mac[ETH_ALEN],
360 		      unsigned int vid,
361 		      enum macaccess_entry_type type);
362 int lan966x_mac_forget(struct lan966x *lan966x,
363 		       const unsigned char mac[ETH_ALEN],
364 		       unsigned int vid,
365 		       enum macaccess_entry_type type);
366 int lan966x_mac_cpu_learn(struct lan966x *lan966x, const char *addr, u16 vid);
367 int lan966x_mac_cpu_forget(struct lan966x *lan966x, const char *addr, u16 vid);
368 void lan966x_mac_init(struct lan966x *lan966x);
369 void lan966x_mac_set_ageing(struct lan966x *lan966x,
370 			    u32 ageing);
371 int lan966x_mac_del_entry(struct lan966x *lan966x,
372 			  const unsigned char *addr,
373 			  u16 vid);
374 int lan966x_mac_add_entry(struct lan966x *lan966x,
375 			  struct lan966x_port *port,
376 			  const unsigned char *addr,
377 			  u16 vid);
378 void lan966x_mac_lag_replace_port_entry(struct lan966x *lan966x,
379 					struct lan966x_port *src,
380 					struct lan966x_port *dst);
381 void lan966x_mac_lag_remove_port_entry(struct lan966x *lan966x,
382 				       struct lan966x_port *src);
383 void lan966x_mac_purge_entries(struct lan966x *lan966x);
384 irqreturn_t lan966x_mac_irq_handler(struct lan966x *lan966x);
385 
386 void lan966x_vlan_init(struct lan966x *lan966x);
387 void lan966x_vlan_port_apply(struct lan966x_port *port);
388 bool lan966x_vlan_cpu_member_cpu_vlan_mask(struct lan966x *lan966x, u16 vid);
389 void lan966x_vlan_port_set_vlan_aware(struct lan966x_port *port,
390 				      bool vlan_aware);
391 int lan966x_vlan_port_set_vid(struct lan966x_port *port,
392 			      u16 vid,
393 			      bool pvid,
394 			      bool untagged);
395 void lan966x_vlan_port_add_vlan(struct lan966x_port *port,
396 				u16 vid,
397 				bool pvid,
398 				bool untagged);
399 void lan966x_vlan_port_del_vlan(struct lan966x_port *port, u16 vid);
400 void lan966x_vlan_cpu_add_vlan(struct lan966x *lan966x, u16 vid);
401 void lan966x_vlan_cpu_del_vlan(struct lan966x *lan966x, u16 vid);
402 
403 void lan966x_fdb_write_entries(struct lan966x *lan966x, u16 vid);
404 void lan966x_fdb_erase_entries(struct lan966x *lan966x, u16 vid);
405 int lan966x_fdb_init(struct lan966x *lan966x);
406 void lan966x_fdb_deinit(struct lan966x *lan966x);
407 void lan966x_fdb_flush_workqueue(struct lan966x *lan966x);
408 int lan966x_handle_fdb(struct net_device *dev,
409 		       struct net_device *orig_dev,
410 		       unsigned long event, const void *ctx,
411 		       const struct switchdev_notifier_fdb_info *fdb_info);
412 
413 void lan966x_mdb_init(struct lan966x *lan966x);
414 void lan966x_mdb_deinit(struct lan966x *lan966x);
415 int lan966x_handle_port_mdb_add(struct lan966x_port *port,
416 				const struct switchdev_obj *obj);
417 int lan966x_handle_port_mdb_del(struct lan966x_port *port,
418 				const struct switchdev_obj *obj);
419 void lan966x_mdb_erase_entries(struct lan966x *lan966x, u16 vid);
420 void lan966x_mdb_write_entries(struct lan966x *lan966x, u16 vid);
421 void lan966x_mdb_clear_entries(struct lan966x *lan966x);
422 void lan966x_mdb_restore_entries(struct lan966x *lan966x);
423 
424 int lan966x_ptp_init(struct lan966x *lan966x);
425 void lan966x_ptp_deinit(struct lan966x *lan966x);
426 int lan966x_ptp_hwtstamp_set(struct lan966x_port *port, struct ifreq *ifr);
427 int lan966x_ptp_hwtstamp_get(struct lan966x_port *port, struct ifreq *ifr);
428 void lan966x_ptp_rxtstamp(struct lan966x *lan966x, struct sk_buff *skb,
429 			  u64 timestamp);
430 int lan966x_ptp_txtstamp_request(struct lan966x_port *port,
431 				 struct sk_buff *skb);
432 void lan966x_ptp_txtstamp_release(struct lan966x_port *port,
433 				  struct sk_buff *skb);
434 irqreturn_t lan966x_ptp_irq_handler(int irq, void *args);
435 irqreturn_t lan966x_ptp_ext_irq_handler(int irq, void *args);
436 u32 lan966x_ptp_get_period_ps(void);
437 int lan966x_ptp_gettime64(struct ptp_clock_info *ptp, struct timespec64 *ts);
438 
439 int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev);
440 int lan966x_fdma_change_mtu(struct lan966x *lan966x);
441 void lan966x_fdma_netdev_init(struct lan966x *lan966x, struct net_device *dev);
442 void lan966x_fdma_netdev_deinit(struct lan966x *lan966x, struct net_device *dev);
443 int lan966x_fdma_init(struct lan966x *lan966x);
444 void lan966x_fdma_deinit(struct lan966x *lan966x);
445 irqreturn_t lan966x_fdma_irq_handler(int irq, void *args);
446 
447 int lan966x_lag_port_join(struct lan966x_port *port,
448 			  struct net_device *brport_dev,
449 			  struct net_device *bond,
450 			  struct netlink_ext_ack *extack);
451 void lan966x_lag_port_leave(struct lan966x_port *port, struct net_device *bond);
452 int lan966x_lag_port_prechangeupper(struct net_device *dev,
453 				    struct netdev_notifier_changeupper_info *info);
454 int lan966x_lag_port_changelowerstate(struct net_device *dev,
455 				      struct netdev_notifier_changelowerstate_info *info);
456 int lan966x_lag_netdev_prechangeupper(struct net_device *dev,
457 				      struct netdev_notifier_changeupper_info *info);
458 int lan966x_lag_netdev_changeupper(struct net_device *dev,
459 				   struct netdev_notifier_changeupper_info *info);
460 bool lan966x_lag_first_port(struct net_device *lag, struct net_device *dev);
461 u32 lan966x_lag_get_mask(struct lan966x *lan966x, struct net_device *bond);
462 
463 int lan966x_port_changeupper(struct net_device *dev,
464 			     struct net_device *brport_dev,
465 			     struct netdev_notifier_changeupper_info *info);
466 int lan966x_port_prechangeupper(struct net_device *dev,
467 				struct net_device *brport_dev,
468 				struct netdev_notifier_changeupper_info *info);
469 void lan966x_port_stp_state_set(struct lan966x_port *port, u8 state);
470 void lan966x_port_ageing_set(struct lan966x_port *port,
471 			     unsigned long ageing_clock_t);
472 void lan966x_update_fwd_mask(struct lan966x *lan966x);
473 
474 int lan966x_tc_setup(struct net_device *dev, enum tc_setup_type type,
475 		     void *type_data);
476 
477 int lan966x_mqprio_add(struct lan966x_port *port, u8 num_tc);
478 int lan966x_mqprio_del(struct lan966x_port *port);
479 
480 void lan966x_taprio_init(struct lan966x *lan966x);
481 void lan966x_taprio_deinit(struct lan966x *lan966x);
482 int lan966x_taprio_add(struct lan966x_port *port,
483 		       struct tc_taprio_qopt_offload *qopt);
484 int lan966x_taprio_del(struct lan966x_port *port);
485 int lan966x_taprio_speed_set(struct lan966x_port *port, int speed);
486 
487 int lan966x_tbf_add(struct lan966x_port *port,
488 		    struct tc_tbf_qopt_offload *qopt);
489 int lan966x_tbf_del(struct lan966x_port *port,
490 		    struct tc_tbf_qopt_offload *qopt);
491 
492 int lan966x_cbs_add(struct lan966x_port *port,
493 		    struct tc_cbs_qopt_offload *qopt);
494 int lan966x_cbs_del(struct lan966x_port *port,
495 		    struct tc_cbs_qopt_offload *qopt);
496 
497 int lan966x_ets_add(struct lan966x_port *port,
498 		    struct tc_ets_qopt_offload *qopt);
499 int lan966x_ets_del(struct lan966x_port *port,
500 		    struct tc_ets_qopt_offload *qopt);
501 
502 int lan966x_tc_matchall(struct lan966x_port *port,
503 			struct tc_cls_matchall_offload *f,
504 			bool ingress);
505 
506 int lan966x_police_port_add(struct lan966x_port *port,
507 			    struct flow_action *action,
508 			    struct flow_action_entry *act,
509 			    unsigned long police_id,
510 			    bool ingress,
511 			    struct netlink_ext_ack *extack);
512 int lan966x_police_port_del(struct lan966x_port *port,
513 			    unsigned long police_id,
514 			    struct netlink_ext_ack *extack);
515 void lan966x_police_port_stats(struct lan966x_port *port,
516 			       struct flow_stats *stats);
517 
518 int lan966x_mirror_port_add(struct lan966x_port *port,
519 			    struct flow_action_entry *action,
520 			    unsigned long mirror_id,
521 			    bool ingress,
522 			    struct netlink_ext_ack *extack);
523 int lan966x_mirror_port_del(struct lan966x_port *port,
524 			    bool ingress,
525 			    struct netlink_ext_ack *extack);
526 void lan966x_mirror_port_stats(struct lan966x_port *port,
527 			       struct flow_stats *stats,
528 			       bool ingress);
529 
lan_addr(void __iomem * base[],int id,int tinst,int tcnt,int gbase,int ginst,int gcnt,int gwidth,int raddr,int rinst,int rcnt,int rwidth)530 static inline void __iomem *lan_addr(void __iomem *base[],
531 				     int id, int tinst, int tcnt,
532 				     int gbase, int ginst,
533 				     int gcnt, int gwidth,
534 				     int raddr, int rinst,
535 				     int rcnt, int rwidth)
536 {
537 	WARN_ON((tinst) >= tcnt);
538 	WARN_ON((ginst) >= gcnt);
539 	WARN_ON((rinst) >= rcnt);
540 	return base[id + (tinst)] +
541 		gbase + ((ginst) * gwidth) +
542 		raddr + ((rinst) * rwidth);
543 }
544 
lan_rd(struct lan966x * lan966x,int id,int tinst,int tcnt,int gbase,int ginst,int gcnt,int gwidth,int raddr,int rinst,int rcnt,int rwidth)545 static inline u32 lan_rd(struct lan966x *lan966x, int id, int tinst, int tcnt,
546 			 int gbase, int ginst, int gcnt, int gwidth,
547 			 int raddr, int rinst, int rcnt, int rwidth)
548 {
549 	return readl(lan_addr(lan966x->regs, id, tinst, tcnt, gbase, ginst,
550 			      gcnt, gwidth, raddr, rinst, rcnt, rwidth));
551 }
552 
lan_wr(u32 val,struct lan966x * lan966x,int id,int tinst,int tcnt,int gbase,int ginst,int gcnt,int gwidth,int raddr,int rinst,int rcnt,int rwidth)553 static inline void lan_wr(u32 val, struct lan966x *lan966x,
554 			  int id, int tinst, int tcnt,
555 			  int gbase, int ginst, int gcnt, int gwidth,
556 			  int raddr, int rinst, int rcnt, int rwidth)
557 {
558 	writel(val, lan_addr(lan966x->regs, id, tinst, tcnt,
559 			     gbase, ginst, gcnt, gwidth,
560 			     raddr, rinst, rcnt, rwidth));
561 }
562 
lan_rmw(u32 val,u32 mask,struct lan966x * lan966x,int id,int tinst,int tcnt,int gbase,int ginst,int gcnt,int gwidth,int raddr,int rinst,int rcnt,int rwidth)563 static inline void lan_rmw(u32 val, u32 mask, struct lan966x *lan966x,
564 			   int id, int tinst, int tcnt,
565 			   int gbase, int ginst, int gcnt, int gwidth,
566 			   int raddr, int rinst, int rcnt, int rwidth)
567 {
568 	u32 nval;
569 
570 	nval = readl(lan_addr(lan966x->regs, id, tinst, tcnt, gbase, ginst,
571 			      gcnt, gwidth, raddr, rinst, rcnt, rwidth));
572 	nval = (nval & ~mask) | (val & mask);
573 	writel(nval, lan_addr(lan966x->regs, id, tinst, tcnt, gbase, ginst,
574 			      gcnt, gwidth, raddr, rinst, rcnt, rwidth));
575 }
576 
577 #endif /* __LAN966X_MAIN_H__ */
578