Linux Audio

Check our new training course

Linux kernel drivers training

May 6-19, 2025
Register
Loading...
v6.8
   1/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
   2/* Copyright 2013-2016 Freescale Semiconductor Inc.
   3 * Copyright 2016 NXP
   4 * Copyright 2020 NXP
   5 */
   6#ifndef __FSL_DPNI_H
   7#define __FSL_DPNI_H
   8
   9#include "dpkg.h"
  10
  11struct fsl_mc_io;
  12
  13/* Data Path Network Interface API
 
  14 * Contains initialization APIs and runtime control APIs for DPNI
  15 */
  16
  17/** General DPNI macros */
  18
  19/**
  20 * DPNI_MAX_TC - Maximum number of traffic classes
  21 */
  22#define DPNI_MAX_TC				8
  23/**
  24 * DPNI_MAX_DPBP - Maximum number of buffer pools per DPNI
  25 */
  26#define DPNI_MAX_DPBP				8
  27
  28/**
  29 * DPNI_ALL_TCS - All traffic classes considered; see dpni_set_queue()
  30 */
  31#define DPNI_ALL_TCS				(u8)(-1)
  32/**
  33 * DPNI_ALL_TC_FLOWS - All flows within traffic class considered; see
  34 * dpni_set_queue()
  35 */
  36#define DPNI_ALL_TC_FLOWS			(u16)(-1)
  37/**
  38 * DPNI_NEW_FLOW_ID - Generate new flow ID; see dpni_set_queue()
  39 */
  40#define DPNI_NEW_FLOW_ID			(u16)(-1)
  41
  42/**
  43 * DPNI_OPT_TX_FRM_RELEASE - Tx traffic is always released to a buffer pool on
  44 * transmit, there are no resources allocated to have the frames confirmed back
  45 * to the source after transmission.
  46 */
  47#define DPNI_OPT_TX_FRM_RELEASE			0x000001
  48/**
  49 * DPNI_OPT_NO_MAC_FILTER - Disables support for MAC address filtering for
  50 * addresses other than primary MAC address. This affects both unicast and
  51 * multicast. Promiscuous mode can still be enabled/disabled for both unicast
  52 * and multicast. If promiscuous mode is disabled, only traffic matching the
  53 * primary MAC address will be accepted.
  54 */
  55#define DPNI_OPT_NO_MAC_FILTER			0x000002
  56/**
  57 * DPNI_OPT_HAS_POLICING - Allocate policers for this DPNI. They can be used to
  58 * rate-limit traffic per traffic class (TC) basis.
  59 */
  60#define DPNI_OPT_HAS_POLICING			0x000004
  61/**
  62 * DPNI_OPT_SHARED_CONGESTION - Congestion can be managed in several ways,
  63 * allowing the buffer pool to deplete on ingress, taildrop on each queue or
  64 * use congestion groups for sets of queues. If set, it configures a single
  65 * congestion groups across all TCs.  If reset, a congestion group is allocated
  66 * for each TC. Only relevant if the DPNI has multiple traffic classes.
  67 */
  68#define DPNI_OPT_SHARED_CONGESTION		0x000008
  69/**
  70 * DPNI_OPT_HAS_KEY_MASKING - Enables TCAM for Flow Steering and QoS look-ups.
  71 * If not specified, all look-ups are exact match. Note that TCAM is not
  72 * available on LS1088 and its variants. Setting this bit on these SoCs will
  73 * trigger an error.
  74 */
  75#define DPNI_OPT_HAS_KEY_MASKING		0x000010
  76/**
  77 * DPNI_OPT_NO_FS - Disables the flow steering table.
  78 */
  79#define DPNI_OPT_NO_FS				0x000020
  80/**
  81 * DPNI_OPT_SHARED_FS - Flow steering table is shared between all traffic
  82 * classes
  83 */
  84#define DPNI_OPT_SHARED_FS			0x001000
  85
  86int dpni_open(struct fsl_mc_io	*mc_io,
  87	      u32		cmd_flags,
  88	      int		dpni_id,
  89	      u16		*token);
  90
  91int dpni_close(struct fsl_mc_io	*mc_io,
  92	       u32		cmd_flags,
  93	       u16		token);
  94
  95#define DPNI_POOL_ASSOC_QPRI	0
  96#define DPNI_POOL_ASSOC_QDBIN	1
  97
  98/**
  99 * struct dpni_pools_cfg - Structure representing buffer pools configuration
 100 * @num_dpbp: Number of DPBPs
 101 * @pool_options: Buffer assignment options.
 102 *	This field is a combination of DPNI_POOL_ASSOC_flags
 103 * @pools: Array of buffer pools parameters; The number of valid entries
 104 *	must match 'num_dpbp' value
 105 * @pools.dpbp_id: DPBP object ID
 106 * @pools.priority: Priority mask that indicates TC's used with this buffer.
 107 *	If set to 0x00 MC will assume value 0xff.
 108 * @pools.buffer_size: Buffer size
 109 * @pools.backup_pool: Backup pool
 110 */
 111struct dpni_pools_cfg {
 112	u8		num_dpbp;
 113	u8		pool_options;
 114	struct {
 115		int	dpbp_id;
 116		u8	priority_mask;
 117		u16	buffer_size;
 118		int	backup_pool;
 119	} pools[DPNI_MAX_DPBP];
 120};
 121
 122int dpni_set_pools(struct fsl_mc_io		*mc_io,
 123		   u32				cmd_flags,
 124		   u16				token,
 125		   const struct dpni_pools_cfg	*cfg);
 126
 127int dpni_enable(struct fsl_mc_io	*mc_io,
 128		u32			cmd_flags,
 129		u16			token);
 130
 131int dpni_disable(struct fsl_mc_io	*mc_io,
 132		 u32			cmd_flags,
 133		 u16			token);
 134
 135int dpni_is_enabled(struct fsl_mc_io	*mc_io,
 136		    u32			cmd_flags,
 137		    u16			token,
 138		    int			*en);
 139
 140int dpni_reset(struct fsl_mc_io	*mc_io,
 141	       u32		cmd_flags,
 142	       u16		token);
 143
 144/* DPNI IRQ Index and Events */
 
 
 145
 
 
 
 146#define DPNI_IRQ_INDEX				0
 147
 148/* DPNI_IRQ_EVENT_LINK_CHANGED - indicates a change in link state */
 
 
 
 149#define DPNI_IRQ_EVENT_LINK_CHANGED		0x00000001
 150
 151/* DPNI_IRQ_EVENT_ENDPOINT_CHANGED - indicates a change in endpoint */
 152#define DPNI_IRQ_EVENT_ENDPOINT_CHANGED		0x00000002
 153
 154int dpni_set_irq_enable(struct fsl_mc_io	*mc_io,
 155			u32			cmd_flags,
 156			u16			token,
 157			u8			irq_index,
 158			u8			en);
 159
 160int dpni_get_irq_enable(struct fsl_mc_io	*mc_io,
 161			u32			cmd_flags,
 162			u16			token,
 163			u8			irq_index,
 164			u8			*en);
 165
 166int dpni_set_irq_mask(struct fsl_mc_io	*mc_io,
 167		      u32		cmd_flags,
 168		      u16		token,
 169		      u8		irq_index,
 170		      u32		mask);
 171
 172int dpni_get_irq_mask(struct fsl_mc_io	*mc_io,
 173		      u32		cmd_flags,
 174		      u16		token,
 175		      u8		irq_index,
 176		      u32		*mask);
 177
 178int dpni_get_irq_status(struct fsl_mc_io	*mc_io,
 179			u32			cmd_flags,
 180			u16			token,
 181			u8			irq_index,
 182			u32			*status);
 183
 184int dpni_clear_irq_status(struct fsl_mc_io	*mc_io,
 185			  u32			cmd_flags,
 186			  u16			token,
 187			  u8			irq_index,
 188			  u32			status);
 189
 190/**
 191 * struct dpni_attr - Structure representing DPNI attributes
 192 * @options: Any combination of the following options:
 193 *		DPNI_OPT_TX_FRM_RELEASE
 194 *		DPNI_OPT_NO_MAC_FILTER
 195 *		DPNI_OPT_HAS_POLICING
 196 *		DPNI_OPT_SHARED_CONGESTION
 197 *		DPNI_OPT_HAS_KEY_MASKING
 198 *		DPNI_OPT_NO_FS
 199 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
 200 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
 201 * @mac_filter_entries: Number of entries in the MAC address filtering table.
 202 * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
 203 * @qos_entries: Number of entries in the QoS classification table.
 204 * @fs_entries: Number of entries in the flow steering table.
 205 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
 206 *		than this when adding QoS entries will result in an error.
 207 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
 208 *		key larger than this when composing the hash + FS key will
 209 *		result in an error.
 210 * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
 211 *		on 6, 5, 5 bits respectively.
 212 */
 213struct dpni_attr {
 214	u32 options;
 215	u8 num_queues;
 216	u8 num_tcs;
 217	u8 mac_filter_entries;
 218	u8 vlan_filter_entries;
 219	u8 qos_entries;
 220	u16 fs_entries;
 221	u8 qos_key_size;
 222	u8 fs_key_size;
 223	u16 wriop_version;
 224};
 225
 226int dpni_get_attributes(struct fsl_mc_io	*mc_io,
 227			u32			cmd_flags,
 228			u16			token,
 229			struct dpni_attr	*attr);
 230
 231/* DPNI errors */
 
 
 232
 233/**
 234 * DPNI_ERROR_EOFHE - Extract out of frame header error
 235 */
 236#define DPNI_ERROR_EOFHE	0x00020000
 237/**
 238 * DPNI_ERROR_FLE - Frame length error
 239 */
 240#define DPNI_ERROR_FLE		0x00002000
 241/**
 242 * DPNI_ERROR_FPE - Frame physical error
 243 */
 244#define DPNI_ERROR_FPE		0x00001000
 245/**
 246 * DPNI_ERROR_PHE - Parsing header error
 247 */
 248#define DPNI_ERROR_PHE		0x00000020
 249/**
 250 * DPNI_ERROR_L3CE - Parser L3 checksum error
 251 */
 252#define DPNI_ERROR_L3CE		0x00000004
 253/**
 254 * DPNI_ERROR_L4CE - Parser L3 checksum error
 255 */
 256#define DPNI_ERROR_L4CE		0x00000001
 257
 258/**
 259 * enum dpni_error_action - Defines DPNI behavior for errors
 260 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
 261 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
 262 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
 263 */
 264enum dpni_error_action {
 265	DPNI_ERROR_ACTION_DISCARD = 0,
 266	DPNI_ERROR_ACTION_CONTINUE = 1,
 267	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
 268};
 269
 270/**
 271 * struct dpni_error_cfg - Structure representing DPNI errors treatment
 272 * @errors: Errors mask; use 'DPNI_ERROR__<X>
 273 * @error_action: The desired action for the errors mask
 274 * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
 275 *		status (FAS); relevant only for the non-discard action
 276 */
 277struct dpni_error_cfg {
 278	u32			errors;
 279	enum dpni_error_action	error_action;
 280	int			set_frame_annotation;
 281};
 282
 283int dpni_set_errors_behavior(struct fsl_mc_io		*mc_io,
 284			     u32			cmd_flags,
 285			     u16			token,
 286			     struct dpni_error_cfg	*cfg);
 287
 288/* DPNI buffer layout modification options */
 
 
 289
 290/**
 291 * DPNI_BUF_LAYOUT_OPT_TIMESTAMP - Select to modify the time-stamp setting
 292 */
 293#define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
 294/**
 295 * DPNI_BUF_LAYOUT_OPT_PARSER_RESULT - Select to modify the parser-result
 296 * setting; not applicable for Tx
 297 */
 298#define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
 299/**
 300 * DPNI_BUF_LAYOUT_OPT_FRAME_STATUS - Select to modify the frame-status setting
 301 */
 302#define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
 303/**
 304 * DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE - Select to modify the private-data-size setting
 305 */
 306#define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
 307/**
 308 * DPNI_BUF_LAYOUT_OPT_DATA_ALIGN - Select to modify the data-alignment setting
 309 */
 310#define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
 311/**
 312 * DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM - Select to modify the data-head-room setting
 313 */
 314#define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
 315/**
 316 * DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM - Select to modify the data-tail-room setting
 317 */
 318#define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
 319
 320/**
 321 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
 322 * @options: Flags representing the suggested modifications to the buffer
 323 *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
 324 * @pass_timestamp: Pass timestamp value
 325 * @pass_parser_result: Pass parser results
 326 * @pass_frame_status: Pass frame status
 327 * @private_data_size: Size kept for private data (in bytes)
 328 * @data_align: Data alignment
 329 * @data_head_room: Data head room
 330 * @data_tail_room: Data tail room
 331 */
 332struct dpni_buffer_layout {
 333	u32	options;
 334	int	pass_timestamp;
 335	int	pass_parser_result;
 336	int	pass_frame_status;
 337	u16	private_data_size;
 338	u16	data_align;
 339	u16	data_head_room;
 340	u16	data_tail_room;
 341};
 342
 343/**
 344 * enum dpni_queue_type - Identifies a type of queue targeted by the command
 345 * @DPNI_QUEUE_RX: Rx queue
 346 * @DPNI_QUEUE_TX: Tx queue
 347 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
 348 * @DPNI_QUEUE_RX_ERR: Rx error queue
 349 */
 350enum dpni_queue_type {
 351	DPNI_QUEUE_RX,
 352	DPNI_QUEUE_TX,
 353	DPNI_QUEUE_TX_CONFIRM,
 354	DPNI_QUEUE_RX_ERR,
 355};
 356
 357int dpni_get_buffer_layout(struct fsl_mc_io		*mc_io,
 358			   u32				cmd_flags,
 359			   u16				token,
 360			   enum dpni_queue_type		qtype,
 361			   struct dpni_buffer_layout	*layout);
 362
 363int dpni_set_buffer_layout(struct fsl_mc_io		   *mc_io,
 364			   u32				   cmd_flags,
 365			   u16				   token,
 366			   enum dpni_queue_type		   qtype,
 367			   const struct dpni_buffer_layout *layout);
 368
 369/**
 370 * enum dpni_offload - Identifies a type of offload targeted by the command
 371 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
 372 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
 373 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
 374 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
 375 */
 376enum dpni_offload {
 377	DPNI_OFF_RX_L3_CSUM,
 378	DPNI_OFF_RX_L4_CSUM,
 379	DPNI_OFF_TX_L3_CSUM,
 380	DPNI_OFF_TX_L4_CSUM,
 381};
 382
 383int dpni_set_offload(struct fsl_mc_io	*mc_io,
 384		     u32		cmd_flags,
 385		     u16		token,
 386		     enum dpni_offload	type,
 387		     u32		config);
 388
 389int dpni_get_offload(struct fsl_mc_io	*mc_io,
 390		     u32		cmd_flags,
 391		     u16		token,
 392		     enum dpni_offload	type,
 393		     u32		*config);
 394
 395int dpni_get_qdid(struct fsl_mc_io	*mc_io,
 396		  u32			cmd_flags,
 397		  u16			token,
 398		  enum dpni_queue_type	qtype,
 399		  u16			*qdid);
 400
 401int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
 402			    u32			cmd_flags,
 403			    u16			token,
 404			    u16			*data_offset);
 405
 406#define DPNI_STATISTICS_CNT		7
 407
 408/**
 409 * union dpni_statistics - Union describing the DPNI statistics
 410 * @page_0: Page_0 statistics structure
 411 * @page_0.ingress_all_frames: Ingress frame count
 412 * @page_0.ingress_all_bytes: Ingress byte count
 413 * @page_0.ingress_multicast_frames: Ingress multicast frame count
 414 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
 415 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
 416 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
 417 * @page_1: Page_1 statistics structure
 418 * @page_1.egress_all_frames: Egress frame count
 419 * @page_1.egress_all_bytes: Egress byte count
 420 * @page_1.egress_multicast_frames: Egress multicast frame count
 421 * @page_1.egress_multicast_bytes: Egress multicast byte count
 422 * @page_1.egress_broadcast_frames: Egress broadcast frame count
 423 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
 424 * @page_2: Page_2 statistics structure
 425 * @page_2.ingress_filtered_frames: Ingress filtered frame count
 426 * @page_2.ingress_discarded_frames: Ingress discarded frame count
 427 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
 428 *	lack of buffers
 429 * @page_2.egress_discarded_frames: Egress discarded frame count
 430 * @page_2.egress_confirmed_frames: Egress confirmed frame count
 431 * @page_3: Page_3 statistics structure
 432 * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
 433 *	dequeued from egress FQs
 434 * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
 435 *	dequeued from egress FQs
 436 * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
 437 *	egress frames whose enqueue was rejected
 438 * @page_3.egress_reject_frames: Cumulative count of the number of egress
 439 *	frames whose enqueue was rejected
 440 * @page_4: Page_4 statistics structure: congestion points
 441 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
 442 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
 443 * @page_5: Page_5 statistics structure: policer
 444 * @page_5.policer_cnt_red: NUmber of red colored frames
 445 * @page_5.policer_cnt_yellow: number of yellow colored frames
 446 * @page_5.policer_cnt_green: number of green colored frames
 447 * @page_5.policer_cnt_re_red: number of recolored red frames
 448 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
 449 * @page_6: Page_6 statistics structure
 450 * @page_6.tx_pending_frames: total number of frames pending in egress FQs
 451 * @raw: raw statistics structure, used to index counters
 452 */
 453union dpni_statistics {
 454	struct {
 455		u64 ingress_all_frames;
 456		u64 ingress_all_bytes;
 457		u64 ingress_multicast_frames;
 458		u64 ingress_multicast_bytes;
 459		u64 ingress_broadcast_frames;
 460		u64 ingress_broadcast_bytes;
 461	} page_0;
 462	struct {
 463		u64 egress_all_frames;
 464		u64 egress_all_bytes;
 465		u64 egress_multicast_frames;
 466		u64 egress_multicast_bytes;
 467		u64 egress_broadcast_frames;
 468		u64 egress_broadcast_bytes;
 469	} page_1;
 470	struct {
 471		u64 ingress_filtered_frames;
 472		u64 ingress_discarded_frames;
 473		u64 ingress_nobuffer_discards;
 474		u64 egress_discarded_frames;
 475		u64 egress_confirmed_frames;
 476	} page_2;
 477	struct {
 478		u64 egress_dequeue_bytes;
 479		u64 egress_dequeue_frames;
 480		u64 egress_reject_bytes;
 481		u64 egress_reject_frames;
 482	} page_3;
 483	struct {
 484		u64 cgr_reject_frames;
 485		u64 cgr_reject_bytes;
 486	} page_4;
 487	struct {
 488		u64 policer_cnt_red;
 489		u64 policer_cnt_yellow;
 490		u64 policer_cnt_green;
 491		u64 policer_cnt_re_red;
 492		u64 policer_cnt_re_yellow;
 493	} page_5;
 494	struct {
 495		u64 tx_pending_frames;
 496	} page_6;
 497	struct {
 498		u64 counter[DPNI_STATISTICS_CNT];
 499	} raw;
 500};
 501
 502int dpni_get_statistics(struct fsl_mc_io	*mc_io,
 503			u32			cmd_flags,
 504			u16			token,
 505			u8			page,
 506			union dpni_statistics	*stat);
 507
 
 
 
 508#define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
 
 
 
 509#define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
 
 
 
 510#define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
 
 
 
 511#define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
 512#define DPNI_LINK_OPT_PFC_PAUSE		0x0000000000000010ULL
 513
 514/**
 515 * struct dpni_link_cfg - Structure representing DPNI link configuration
 516 * @rate: Rate
 517 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
 518 */
 519struct dpni_link_cfg {
 520	u32 rate;
 521	u64 options;
 522};
 523
 524int dpni_set_link_cfg(struct fsl_mc_io			*mc_io,
 525		      u32				cmd_flags,
 526		      u16				token,
 527		      const struct dpni_link_cfg	*cfg);
 528
 529int dpni_get_link_cfg(struct fsl_mc_io			*mc_io,
 530		      u32				cmd_flags,
 531		      u16				token,
 532		      struct dpni_link_cfg		*cfg);
 533
 534/**
 535 * struct dpni_link_state - Structure representing DPNI link state
 536 * @rate: Rate
 537 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
 538 * @up: Link state; '0' for down, '1' for up
 539 */
 540struct dpni_link_state {
 541	u32	rate;
 542	u64	options;
 543	int	up;
 544};
 545
 546int dpni_get_link_state(struct fsl_mc_io	*mc_io,
 547			u32			cmd_flags,
 548			u16			token,
 549			struct dpni_link_state	*state);
 550
 551int dpni_set_max_frame_length(struct fsl_mc_io	*mc_io,
 552			      u32		cmd_flags,
 553			      u16		token,
 554			      u16		max_frame_length);
 555
 556int dpni_get_max_frame_length(struct fsl_mc_io	*mc_io,
 557			      u32		cmd_flags,
 558			      u16		token,
 559			      u16		*max_frame_length);
 560
 561int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
 562			       u32		cmd_flags,
 563			       u16		token,
 564			       int		en);
 565
 566int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
 567			       u32		cmd_flags,
 568			       u16		token,
 569			       int		*en);
 570
 571int dpni_set_unicast_promisc(struct fsl_mc_io	*mc_io,
 572			     u32		cmd_flags,
 573			     u16		token,
 574			     int		en);
 575
 576int dpni_get_unicast_promisc(struct fsl_mc_io	*mc_io,
 577			     u32		cmd_flags,
 578			     u16		token,
 579			     int		*en);
 580
 581int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
 582			      u32		cmd_flags,
 583			      u16		token,
 584			      const u8		mac_addr[6]);
 585
 586int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
 587			      u32		cmd_flags,
 588			      u16		token,
 589			      u8		mac_addr[6]);
 590
 591int dpni_get_port_mac_addr(struct fsl_mc_io	*mc_io,
 592			   u32			cm_flags,
 593			   u16			token,
 594			   u8			mac_addr[6]);
 595
 596int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
 597		      u32		cmd_flags,
 598		      u16		token,
 599		      const u8		mac_addr[6]);
 600
 601int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
 602			 u32			cmd_flags,
 603			 u16			token,
 604			 const u8		mac_addr[6]);
 605
 606int dpni_clear_mac_filters(struct fsl_mc_io	*mc_io,
 607			   u32			cmd_flags,
 608			   u16			token,
 609			   int			unicast,
 610			   int			multicast);
 611
 612/**
 613 * enum dpni_dist_mode - DPNI distribution mode
 614 * @DPNI_DIST_MODE_NONE: No distribution
 615 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
 616 *		the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
 617 * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
 618 *	 the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
 619 */
 620enum dpni_dist_mode {
 621	DPNI_DIST_MODE_NONE = 0,
 622	DPNI_DIST_MODE_HASH = 1,
 623	DPNI_DIST_MODE_FS = 2
 624};
 625
 626/**
 627 * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
 628 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
 629 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
 630 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
 631 */
 632enum dpni_fs_miss_action {
 633	DPNI_FS_MISS_DROP = 0,
 634	DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
 635	DPNI_FS_MISS_HASH = 2
 636};
 637
 638/**
 639 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
 640 * @miss_action: Miss action selection
 641 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
 642 */
 643struct dpni_fs_tbl_cfg {
 644	enum dpni_fs_miss_action	miss_action;
 645	u16				default_flow_id;
 646};
 647
 648int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
 649			 u8 *key_cfg_buf);
 650
 651/**
 652 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
 653 * @dist_size: Set the distribution size;
 654 *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
 655 *	112,128,192,224,256,384,448,512,768,896,1024
 656 * @dist_mode: Distribution mode
 657 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 658 *		the extractions to be used for the distribution key by calling
 659 *		dpni_prepare_key_cfg() relevant only when
 660 *		'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
 661 * @fs_cfg: Flow Steering table configuration; only relevant if
 662 *		'dist_mode = DPNI_DIST_MODE_FS'
 663 */
 664struct dpni_rx_tc_dist_cfg {
 665	u16			dist_size;
 666	enum dpni_dist_mode	dist_mode;
 667	u64			key_cfg_iova;
 668	struct dpni_fs_tbl_cfg	fs_cfg;
 669};
 670
 671int dpni_set_rx_tc_dist(struct fsl_mc_io			*mc_io,
 672			u32					cmd_flags,
 673			u16					token,
 674			u8					tc_id,
 675			const struct dpni_rx_tc_dist_cfg	*cfg);
 676
 677/**
 678 * DPNI_FS_MISS_DROP - When used for fs_miss_flow_id in function
 679 * dpni_set_rx_dist, will signal to dpni to drop all unclassified frames
 680 */
 681#define DPNI_FS_MISS_DROP		((uint16_t)-1)
 682
 683/**
 684 * struct dpni_rx_dist_cfg - Rx distribution configuration
 685 * @dist_size:	distribution size
 686 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 687 *		the extractions to be used for the distribution key by calling
 688 *		dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
 689 *		it can be '0'
 690 * @enable: enable/disable the distribution.
 691 * @tc: TC id for which distribution is set
 692 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
 693 *		hash is disabled it will be put into this queue id; use
 694 *		DPNI_FS_MISS_DROP to drop frames. The value of this field is
 695 *		used only when flow steering distribution is enabled and hash
 696 *		distribution is disabled
 697 */
 698struct dpni_rx_dist_cfg {
 699	u16 dist_size;
 700	u64 key_cfg_iova;
 701	u8 enable;
 702	u8 tc;
 703	u16 fs_miss_flow_id;
 704};
 705
 706int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
 707			u32 cmd_flags,
 708			u16 token,
 709			const struct dpni_rx_dist_cfg *cfg);
 710
 711int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
 712			  u32 cmd_flags,
 713			  u16 token,
 714			  const struct dpni_rx_dist_cfg *cfg);
 715
 716/**
 717 * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
 718 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
 719 *		key extractions to be used as the QoS criteria by calling
 720 *		dpkg_prepare_key_cfg()
 721 * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
 722 *		'0' to use the 'default_tc' in such cases
 723 * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
 724 */
 725struct dpni_qos_tbl_cfg {
 726	u64 key_cfg_iova;
 727	int discard_on_miss;
 728	u8 default_tc;
 729};
 730
 731int dpni_set_qos_table(struct fsl_mc_io *mc_io,
 732		       u32 cmd_flags,
 733		       u16 token,
 734		       const struct dpni_qos_tbl_cfg *cfg);
 735
 736/**
 737 * enum dpni_dest - DPNI destination types
 738 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
 739 *		does not generate FQDAN notifications; user is expected to
 740 *		dequeue from the queue based on polling or other user-defined
 741 *		method
 742 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
 743 *		notifications to the specified DPIO; user is expected to dequeue
 744 *		from the queue only after notification is received
 745 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
 746 *		FQDAN notifications, but is connected to the specified DPCON
 747 *		object; user is expected to dequeue from the DPCON channel
 748 */
 749enum dpni_dest {
 750	DPNI_DEST_NONE = 0,
 751	DPNI_DEST_DPIO = 1,
 752	DPNI_DEST_DPCON = 2
 753};
 754
 755/**
 756 * struct dpni_queue - Queue structure
 757 * @destination: - Destination structure
 758 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
 759 *	Identifies either a DPIO or a DPCON object.
 760 *	Not relevant for Tx queues.
 761 * @destination.type:	May be one of the following:
 762 *	0 - No destination, queue can be manually
 763 *		queried, but will not push traffic or
 764 *		notifications to a DPIO;
 765 *	1 - The destination is a DPIO. When traffic
 766 *		becomes available in the queue a FQDAN
 767 *		(FQ data available notification) will be
 768 *		generated to selected DPIO;
 769 *	2 - The destination is a DPCON. The queue is
 770 *		associated with a DPCON object for the
 771 *		purpose of scheduling between multiple
 772 *		queues. The DPCON may be independently
 773 *		configured to generate notifications.
 774 *		Not relevant for Tx queues.
 775 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
 776 *	in a DPIO during dequeue to reduce spread of traffic.
 777 *	Only relevant if queues are
 778 *	not affined to a single DPIO.
 779 * @user_context: User data, presented to the user along with any frames
 780 *	from this queue. Not relevant for Tx queues.
 781 * @flc: FD FLow Context structure
 782 * @flc.value: Default FLC value for traffic dequeued from
 783 *      this queue.  Please check description of FD
 784 *      structure for more information.
 785 *      Note that FLC values set using dpni_add_fs_entry,
 786 *      if any, take precedence over values per queue.
 787 * @flc.stash_control: Boolean, indicates whether the 6 lowest
 788 *      - significant bits are used for stash control.
 789 *      significant bits are used for stash control.  If set, the 6
 790 *      least significant bits in value are interpreted as follows:
 791 *      - bits 0-1: indicates the number of 64 byte units of context
 792 *      that are stashed.  FLC value is interpreted as a memory address
 793 *      in this case, excluding the 6 LS bits.
 794 *      - bits 2-3: indicates the number of 64 byte units of frame
 795 *      annotation to be stashed.  Annotation is placed at FD[ADDR].
 796 *      - bits 4-5: indicates the number of 64 byte units of frame
 797 *      data to be stashed.  Frame data is placed at FD[ADDR] +
 798 *      FD[OFFSET].
 799 *      For more details check the Frame Descriptor section in the
 800 *      hardware documentation.
 801 */
 802struct dpni_queue {
 803	struct {
 804		u16 id;
 805		enum dpni_dest type;
 806		char hold_active;
 807		u8 priority;
 808	} destination;
 809	u64 user_context;
 810	struct {
 811		u64 value;
 812		char stash_control;
 813	} flc;
 814};
 815
 816/**
 817 * struct dpni_queue_id - Queue identification, used for enqueue commands
 818 *			or queue control
 819 * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
 820 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
 821 *		for Tx queues.
 822 */
 823struct dpni_queue_id {
 824	u32 fqid;
 825	u16 qdbin;
 826};
 827
 828/* Set User Context */
 
 
 829#define DPNI_QUEUE_OPT_USER_CTX		0x00000001
 830#define DPNI_QUEUE_OPT_DEST		0x00000002
 831#define DPNI_QUEUE_OPT_FLC		0x00000004
 832#define DPNI_QUEUE_OPT_HOLD_ACTIVE	0x00000008
 833
 834int dpni_set_queue(struct fsl_mc_io	*mc_io,
 835		   u32			cmd_flags,
 836		   u16			token,
 837		   enum dpni_queue_type	qtype,
 838		   u8			tc,
 839		   u8			index,
 840		   u8			options,
 841		   const struct dpni_queue *queue);
 842
 843int dpni_get_queue(struct fsl_mc_io	*mc_io,
 844		   u32			cmd_flags,
 845		   u16			token,
 846		   enum dpni_queue_type	qtype,
 847		   u8			tc,
 848		   u8			index,
 849		   struct dpni_queue	*queue,
 850		   struct dpni_queue_id	*qid);
 851
 852/**
 853 * enum dpni_congestion_unit - DPNI congestion units
 854 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
 855 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
 856 */
 857enum dpni_congestion_unit {
 858	DPNI_CONGESTION_UNIT_BYTES = 0,
 859	DPNI_CONGESTION_UNIT_FRAMES
 860};
 861
 862/**
 863 * enum dpni_congestion_point - Structure representing congestion point
 864 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
 865 *		QUEUE_INDEX
 866 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
 867 *		define the DPNI this can be either per TC (default) or per
 868 *		interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
 869 *		QUEUE_INDEX is ignored if this type is used.
 870 */
 871enum dpni_congestion_point {
 872	DPNI_CP_QUEUE,
 873	DPNI_CP_GROUP,
 874};
 875
 876/**
 877 * struct dpni_dest_cfg - Structure representing DPNI destination parameters
 878 * @dest_type:	Destination type
 879 * @dest_id:	Either DPIO ID or DPCON ID, depending on the destination type
 880 * @priority:	Priority selection within the DPIO or DPCON channel; valid
 881 *		values are 0-1 or 0-7, depending on the number of priorities
 882 *		in that channel; not relevant for 'DPNI_DEST_NONE' option
 883 */
 884struct dpni_dest_cfg {
 885	enum dpni_dest dest_type;
 886	int dest_id;
 887	u8 priority;
 888};
 889
 890/* DPNI congestion options */
 891
 892/**
 893 * DPNI_CONG_OPT_FLOW_CONTROL - This congestion will trigger flow control or
 894 * priority flow control.  This will have effect only if flow control is
 895 * enabled with dpni_set_link_cfg().
 896 */
 897#define DPNI_CONG_OPT_FLOW_CONTROL		0x00000040
 898
 899/**
 900 * struct dpni_congestion_notification_cfg - congestion notification
 901 *					configuration
 902 * @units: Units type
 903 * @threshold_entry: Above this threshold we enter a congestion state.
 904 *		set it to '0' to disable it
 905 * @threshold_exit: Below this threshold we exit the congestion state.
 906 * @message_ctx: The context that will be part of the CSCN message
 907 * @message_iova: I/O virtual address (must be in DMA-able memory),
 908 *		must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
 909 *		is contained in 'options'
 910 * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
 911 * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
 912 */
 913
 914struct dpni_congestion_notification_cfg {
 915	enum dpni_congestion_unit units;
 916	u32 threshold_entry;
 917	u32 threshold_exit;
 918	u64 message_ctx;
 919	u64 message_iova;
 920	struct dpni_dest_cfg dest_cfg;
 921	u16 notification_mode;
 922};
 923
 924int dpni_set_congestion_notification(
 925			struct fsl_mc_io *mc_io,
 926			u32 cmd_flags,
 927			u16 token,
 928			enum dpni_queue_type qtype,
 929			u8 tc_id,
 930			const struct dpni_congestion_notification_cfg *cfg);
 931
 932/**
 933 * struct dpni_taildrop - Structure representing the taildrop
 934 * @enable:	Indicates whether the taildrop is active or not.
 935 * @units:	Indicates the unit of THRESHOLD. Queue taildrop only supports
 936 *		byte units, this field is ignored and assumed = 0 if
 937 *		CONGESTION_POINT is 0.
 938 * @threshold:	Threshold value, in units identified by UNITS field. Value 0
 939 *		cannot be used as a valid taildrop threshold, THRESHOLD must
 940 *		be > 0 if the taildrop is enabled.
 941 */
 942struct dpni_taildrop {
 943	char enable;
 944	enum dpni_congestion_unit units;
 945	u32 threshold;
 946};
 947
 948int dpni_set_taildrop(struct fsl_mc_io *mc_io,
 949		      u32 cmd_flags,
 950		      u16 token,
 951		      enum dpni_congestion_point cg_point,
 952		      enum dpni_queue_type q_type,
 953		      u8 tc,
 954		      u8 q_index,
 955		      struct dpni_taildrop *taildrop);
 956
 957int dpni_get_taildrop(struct fsl_mc_io *mc_io,
 958		      u32 cmd_flags,
 959		      u16 token,
 960		      enum dpni_congestion_point cg_point,
 961		      enum dpni_queue_type q_type,
 962		      u8 tc,
 963		      u8 q_index,
 964		      struct dpni_taildrop *taildrop);
 965
 966/**
 967 * struct dpni_rule_cfg - Rule configuration for table lookup
 968 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
 969 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
 970 * @key_size: key and mask size (in bytes)
 971 */
 972struct dpni_rule_cfg {
 973	u64	key_iova;
 974	u64	mask_iova;
 975	u8	key_size;
 976};
 977
 978/**
 979 * DPNI_FS_OPT_DISCARD - Discard matching traffic. If set, this takes
 980 * precedence over any other configuration and matching traffic is always
 981 * discarded.
 982 */
 983 #define DPNI_FS_OPT_DISCARD            0x1
 984
 985/**
 986 * DPNI_FS_OPT_SET_FLC - Set FLC value. If set, flc member of struct
 987 * dpni_fs_action_cfg is used to override the FLC value set per queue.
 988 * For more details check the Frame Descriptor section in the hardware
 989 * documentation.
 990 */
 991#define DPNI_FS_OPT_SET_FLC            0x2
 992
 993/**
 994 * DPNI_FS_OPT_SET_STASH_CONTROL - Indicates whether the 6 lowest significant
 995 * bits of FLC are used for stash control. If set, the 6 least significant bits
 996 * in value are interpreted as follows:
 997 *     - bits 0-1: indicates the number of 64 byte units of context that are
 998 *     stashed. FLC value is interpreted as a memory address in this case,
 999 *     excluding the 6 LS bits.
1000 *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1001 *     to be stashed. Annotation is placed at FD[ADDR].
1002 *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1003 *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1004 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1005 */
1006#define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1007
1008/**
1009 * struct dpni_fs_action_cfg - Action configuration for table look-up
1010 * @flc:	FLC value for traffic matching this rule. Please check the
1011 *		Frame Descriptor section in the hardware documentation for
1012 *		more information.
1013 * @flow_id:	Identifies the Rx queue used for matching traffic. Supported
1014 *		values are in range 0 to num_queue-1.
1015 * @options:	Any combination of DPNI_FS_OPT_ values.
1016 */
1017struct dpni_fs_action_cfg {
1018	u64 flc;
1019	u16 flow_id;
1020	u16 options;
1021};
1022
1023int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1024		      u32 cmd_flags,
1025		      u16 token,
1026		      u8 tc_id,
1027		      u16 index,
1028		      const struct dpni_rule_cfg *cfg,
1029		      const struct dpni_fs_action_cfg *action);
1030
1031int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1032			 u32 cmd_flags,
1033			 u16 token,
1034			 u8 tc_id,
1035			 const struct dpni_rule_cfg *cfg);
1036
1037int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1038		       u32 cmd_flags,
1039		       u16 token,
1040		       const struct dpni_rule_cfg *cfg,
1041		       u8 tc_id,
1042		       u16 index);
1043
1044int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1045			  u32 cmd_flags,
1046			  u16 token,
1047			  const struct dpni_rule_cfg *cfg);
1048
1049int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1050			 u32 cmd_flags,
1051			 u16 token);
1052
1053int dpni_get_api_version(struct fsl_mc_io *mc_io,
1054			 u32 cmd_flags,
1055			 u16 *major_ver,
1056			 u16 *minor_ver);
1057/**
1058 * struct dpni_tx_shaping_cfg - Structure representing DPNI tx shaping configuration
1059 * @rate_limit:		Rate in Mbps
1060 * @max_burst_size:	Burst size in bytes (up to 64KB)
1061 */
1062struct dpni_tx_shaping_cfg {
1063	u32 rate_limit;
1064	u16 max_burst_size;
1065};
1066
1067int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
1068			u32 cmd_flags,
1069			u16 token,
1070			const struct dpni_tx_shaping_cfg *tx_cr_shaper,
1071			const struct dpni_tx_shaping_cfg *tx_er_shaper,
1072			int coupled);
1073
1074/**
1075 * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
1076 * @en:		enable single step PTP. When enabled the PTPv1 functionality
1077 *		will not work. If the field is zero, offset and ch_update
1078 *		parameters will be ignored
1079 * @offset:	start offset from the beginning of the frame where
1080 *		timestamp field is found. The offset must respect all MAC
1081 *		headers, VLAN tags and other protocol headers
1082 * @ch_update:	when set UDP checksum will be updated inside packet
1083 * @peer_delay:	For peer-to-peer transparent clocks add this value to the
1084 *		correction field in addition to the transient time update.
1085 *		The value expresses nanoseconds.
1086 * @ptp_onestep_reg_base: 1588 SINGLE_STEP register base address. This address
1087 *			  is used to update directly the register contents.
1088 *			  User has to create an address mapping for it.
1089 *
1090 *
1091 */
1092struct dpni_single_step_cfg {
1093	u8	en;
1094	u8	ch_update;
1095	u16	offset;
1096	u32	peer_delay;
1097	u32	ptp_onestep_reg_base;
1098};
1099
1100int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
1101			     u32 cmd_flags,
1102			     u16 token,
1103			     struct dpni_single_step_cfg *ptp_cfg);
1104
1105int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
1106			     u32 cmd_flags,
1107			     u16 token,
1108			     struct dpni_single_step_cfg *ptp_cfg);
1109
1110int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1111			    u32 en);
1112
1113int dpni_add_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1114		     u16 vlan_id, u8 flags, u8 tc_id, u8 flow_id);
1115
1116int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
1117			u16 vlan_id);
1118
1119#endif /* __FSL_DPNI_H */
v5.4
  1/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
  2/* Copyright 2013-2016 Freescale Semiconductor Inc.
  3 * Copyright 2016 NXP
 
  4 */
  5#ifndef __FSL_DPNI_H
  6#define __FSL_DPNI_H
  7
  8#include "dpkg.h"
  9
 10struct fsl_mc_io;
 11
 12/**
 13 * Data Path Network Interface API
 14 * Contains initialization APIs and runtime control APIs for DPNI
 15 */
 16
 17/** General DPNI macros */
 18
 19/**
 20 * Maximum number of traffic classes
 21 */
 22#define DPNI_MAX_TC				8
 23/**
 24 * Maximum number of buffer pools per DPNI
 25 */
 26#define DPNI_MAX_DPBP				8
 27
 28/**
 29 * All traffic classes considered; see dpni_set_queue()
 30 */
 31#define DPNI_ALL_TCS				(u8)(-1)
 32/**
 33 * All flows within traffic class considered; see dpni_set_queue()
 
 34 */
 35#define DPNI_ALL_TC_FLOWS			(u16)(-1)
 36/**
 37 * Generate new flow ID; see dpni_set_queue()
 38 */
 39#define DPNI_NEW_FLOW_ID			(u16)(-1)
 40
 41/**
 42 * Tx traffic is always released to a buffer pool on transmit, there are no
 43 * resources allocated to have the frames confirmed back to the source after
 44 * transmission.
 45 */
 46#define DPNI_OPT_TX_FRM_RELEASE			0x000001
 47/**
 48 * Disables support for MAC address filtering for addresses other than primary
 49 * MAC address. This affects both unicast and multicast. Promiscuous mode can
 50 * still be enabled/disabled for both unicast and multicast. If promiscuous mode
 51 * is disabled, only traffic matching the primary MAC address will be accepted.
 
 52 */
 53#define DPNI_OPT_NO_MAC_FILTER			0x000002
 54/**
 55 * Allocate policers for this DPNI. They can be used to rate-limit traffic per
 56 * traffic class (TC) basis.
 57 */
 58#define DPNI_OPT_HAS_POLICING			0x000004
 59/**
 60 * Congestion can be managed in several ways, allowing the buffer pool to
 61 * deplete on ingress, taildrop on each queue or use congestion groups for sets
 62 * of queues. If set, it configures a single congestion groups across all TCs.
 63 * If reset, a congestion group is allocated for each TC. Only relevant if the
 64 * DPNI has multiple traffic classes.
 65 */
 66#define DPNI_OPT_SHARED_CONGESTION		0x000008
 67/**
 68 * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
 69 * look-ups are exact match. Note that TCAM is not available on LS1088 and its
 70 * variants. Setting this bit on these SoCs will trigger an error.
 
 71 */
 72#define DPNI_OPT_HAS_KEY_MASKING		0x000010
 73/**
 74 * Disables the flow steering table.
 75 */
 76#define DPNI_OPT_NO_FS				0x000020
 
 
 
 
 
 77
 78int dpni_open(struct fsl_mc_io	*mc_io,
 79	      u32		cmd_flags,
 80	      int		dpni_id,
 81	      u16		*token);
 82
 83int dpni_close(struct fsl_mc_io	*mc_io,
 84	       u32		cmd_flags,
 85	       u16		token);
 86
 
 
 
 87/**
 88 * struct dpni_pools_cfg - Structure representing buffer pools configuration
 89 * @num_dpbp: Number of DPBPs
 
 
 90 * @pools: Array of buffer pools parameters; The number of valid entries
 91 *	must match 'num_dpbp' value
 92 * @pools.dpbp_id: DPBP object ID
 
 
 93 * @pools.buffer_size: Buffer size
 94 * @pools.backup_pool: Backup pool
 95 */
 96struct dpni_pools_cfg {
 97	u8		num_dpbp;
 
 98	struct {
 99		int	dpbp_id;
 
100		u16	buffer_size;
101		int	backup_pool;
102	} pools[DPNI_MAX_DPBP];
103};
104
105int dpni_set_pools(struct fsl_mc_io		*mc_io,
106		   u32				cmd_flags,
107		   u16				token,
108		   const struct dpni_pools_cfg	*cfg);
109
110int dpni_enable(struct fsl_mc_io	*mc_io,
111		u32			cmd_flags,
112		u16			token);
113
114int dpni_disable(struct fsl_mc_io	*mc_io,
115		 u32			cmd_flags,
116		 u16			token);
117
118int dpni_is_enabled(struct fsl_mc_io	*mc_io,
119		    u32			cmd_flags,
120		    u16			token,
121		    int			*en);
122
123int dpni_reset(struct fsl_mc_io	*mc_io,
124	       u32		cmd_flags,
125	       u16		token);
126
127/**
128 * DPNI IRQ Index and Events
129 */
130
131/**
132 * IRQ index
133 */
134#define DPNI_IRQ_INDEX				0
135/**
136 * IRQ events:
137 *       indicates a change in link state
138 *       indicates a change in endpoint
139 */
140#define DPNI_IRQ_EVENT_LINK_CHANGED		0x00000001
 
 
141#define DPNI_IRQ_EVENT_ENDPOINT_CHANGED		0x00000002
142
143int dpni_set_irq_enable(struct fsl_mc_io	*mc_io,
144			u32			cmd_flags,
145			u16			token,
146			u8			irq_index,
147			u8			en);
148
149int dpni_get_irq_enable(struct fsl_mc_io	*mc_io,
150			u32			cmd_flags,
151			u16			token,
152			u8			irq_index,
153			u8			*en);
154
155int dpni_set_irq_mask(struct fsl_mc_io	*mc_io,
156		      u32		cmd_flags,
157		      u16		token,
158		      u8		irq_index,
159		      u32		mask);
160
161int dpni_get_irq_mask(struct fsl_mc_io	*mc_io,
162		      u32		cmd_flags,
163		      u16		token,
164		      u8		irq_index,
165		      u32		*mask);
166
167int dpni_get_irq_status(struct fsl_mc_io	*mc_io,
168			u32			cmd_flags,
169			u16			token,
170			u8			irq_index,
171			u32			*status);
172
173int dpni_clear_irq_status(struct fsl_mc_io	*mc_io,
174			  u32			cmd_flags,
175			  u16			token,
176			  u8			irq_index,
177			  u32			status);
178
179/**
180 * struct dpni_attr - Structure representing DPNI attributes
181 * @options: Any combination of the following options:
182 *		DPNI_OPT_TX_FRM_RELEASE
183 *		DPNI_OPT_NO_MAC_FILTER
184 *		DPNI_OPT_HAS_POLICING
185 *		DPNI_OPT_SHARED_CONGESTION
186 *		DPNI_OPT_HAS_KEY_MASKING
187 *		DPNI_OPT_NO_FS
188 * @num_queues: Number of Tx and Rx queues used for traffic distribution.
189 * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
190 * @mac_filter_entries: Number of entries in the MAC address filtering table.
191 * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
192 * @qos_entries: Number of entries in the QoS classification table.
193 * @fs_entries: Number of entries in the flow steering table.
194 * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
195 *		than this when adding QoS entries will result in an error.
196 * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
197 *		key larger than this when composing the hash + FS key will
198 *		result in an error.
199 * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
200 *		on 6, 5, 5 bits respectively.
201 */
202struct dpni_attr {
203	u32 options;
204	u8 num_queues;
205	u8 num_tcs;
206	u8 mac_filter_entries;
207	u8 vlan_filter_entries;
208	u8 qos_entries;
209	u16 fs_entries;
210	u8 qos_key_size;
211	u8 fs_key_size;
212	u16 wriop_version;
213};
214
215int dpni_get_attributes(struct fsl_mc_io	*mc_io,
216			u32			cmd_flags,
217			u16			token,
218			struct dpni_attr	*attr);
219
220/**
221 * DPNI errors
222 */
223
224/**
225 * Extract out of frame header error
226 */
227#define DPNI_ERROR_EOFHE	0x00020000
228/**
229 * Frame length error
230 */
231#define DPNI_ERROR_FLE		0x00002000
232/**
233 * Frame physical error
234 */
235#define DPNI_ERROR_FPE		0x00001000
236/**
237 * Parsing header error
238 */
239#define DPNI_ERROR_PHE		0x00000020
240/**
241 * Parser L3 checksum error
242 */
243#define DPNI_ERROR_L3CE		0x00000004
244/**
245 * Parser L3 checksum error
246 */
247#define DPNI_ERROR_L4CE		0x00000001
248
249/**
250 * enum dpni_error_action - Defines DPNI behavior for errors
251 * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
252 * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
253 * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
254 */
255enum dpni_error_action {
256	DPNI_ERROR_ACTION_DISCARD = 0,
257	DPNI_ERROR_ACTION_CONTINUE = 1,
258	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
259};
260
261/**
262 * struct dpni_error_cfg - Structure representing DPNI errors treatment
263 * @errors: Errors mask; use 'DPNI_ERROR__<X>
264 * @error_action: The desired action for the errors mask
265 * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
266 *		status (FAS); relevant only for the non-discard action
267 */
268struct dpni_error_cfg {
269	u32			errors;
270	enum dpni_error_action	error_action;
271	int			set_frame_annotation;
272};
273
274int dpni_set_errors_behavior(struct fsl_mc_io		*mc_io,
275			     u32			cmd_flags,
276			     u16			token,
277			     struct dpni_error_cfg	*cfg);
278
279/**
280 * DPNI buffer layout modification options
281 */
282
283/**
284 * Select to modify the time-stamp setting
285 */
286#define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
287/**
288 * Select to modify the parser-result setting; not applicable for Tx
 
289 */
290#define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
291/**
292 * Select to modify the frame-status setting
293 */
294#define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
295/**
296 * Select to modify the private-data-size setting
297 */
298#define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
299/**
300 * Select to modify the data-alignment setting
301 */
302#define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
303/**
304 * Select to modify the data-head-room setting
305 */
306#define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
307/**
308 * Select to modify the data-tail-room setting
309 */
310#define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
311
312/**
313 * struct dpni_buffer_layout - Structure representing DPNI buffer layout
314 * @options: Flags representing the suggested modifications to the buffer
315 *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
316 * @pass_timestamp: Pass timestamp value
317 * @pass_parser_result: Pass parser results
318 * @pass_frame_status: Pass frame status
319 * @private_data_size: Size kept for private data (in bytes)
320 * @data_align: Data alignment
321 * @data_head_room: Data head room
322 * @data_tail_room: Data tail room
323 */
324struct dpni_buffer_layout {
325	u32	options;
326	int	pass_timestamp;
327	int	pass_parser_result;
328	int	pass_frame_status;
329	u16	private_data_size;
330	u16	data_align;
331	u16	data_head_room;
332	u16	data_tail_room;
333};
334
335/**
336 * enum dpni_queue_type - Identifies a type of queue targeted by the command
337 * @DPNI_QUEUE_RX: Rx queue
338 * @DPNI_QUEUE_TX: Tx queue
339 * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
340 * @DPNI_QUEUE_RX_ERR: Rx error queue
341 */enum dpni_queue_type {
 
342	DPNI_QUEUE_RX,
343	DPNI_QUEUE_TX,
344	DPNI_QUEUE_TX_CONFIRM,
345	DPNI_QUEUE_RX_ERR,
346};
347
348int dpni_get_buffer_layout(struct fsl_mc_io		*mc_io,
349			   u32				cmd_flags,
350			   u16				token,
351			   enum dpni_queue_type		qtype,
352			   struct dpni_buffer_layout	*layout);
353
354int dpni_set_buffer_layout(struct fsl_mc_io		   *mc_io,
355			   u32				   cmd_flags,
356			   u16				   token,
357			   enum dpni_queue_type		   qtype,
358			   const struct dpni_buffer_layout *layout);
359
360/**
361 * enum dpni_offload - Identifies a type of offload targeted by the command
362 * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
363 * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
364 * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
365 * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
366 */
367enum dpni_offload {
368	DPNI_OFF_RX_L3_CSUM,
369	DPNI_OFF_RX_L4_CSUM,
370	DPNI_OFF_TX_L3_CSUM,
371	DPNI_OFF_TX_L4_CSUM,
372};
373
374int dpni_set_offload(struct fsl_mc_io	*mc_io,
375		     u32		cmd_flags,
376		     u16		token,
377		     enum dpni_offload	type,
378		     u32		config);
379
380int dpni_get_offload(struct fsl_mc_io	*mc_io,
381		     u32		cmd_flags,
382		     u16		token,
383		     enum dpni_offload	type,
384		     u32		*config);
385
386int dpni_get_qdid(struct fsl_mc_io	*mc_io,
387		  u32			cmd_flags,
388		  u16			token,
389		  enum dpni_queue_type	qtype,
390		  u16			*qdid);
391
392int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
393			    u32			cmd_flags,
394			    u16			token,
395			    u16			*data_offset);
396
397#define DPNI_STATISTICS_CNT		7
398
399/**
400 * union dpni_statistics - Union describing the DPNI statistics
401 * @page_0: Page_0 statistics structure
402 * @page_0.ingress_all_frames: Ingress frame count
403 * @page_0.ingress_all_bytes: Ingress byte count
404 * @page_0.ingress_multicast_frames: Ingress multicast frame count
405 * @page_0.ingress_multicast_bytes: Ingress multicast byte count
406 * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
407 * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
408 * @page_1: Page_1 statistics structure
409 * @page_1.egress_all_frames: Egress frame count
410 * @page_1.egress_all_bytes: Egress byte count
411 * @page_1.egress_multicast_frames: Egress multicast frame count
412 * @page_1.egress_multicast_bytes: Egress multicast byte count
413 * @page_1.egress_broadcast_frames: Egress broadcast frame count
414 * @page_1.egress_broadcast_bytes: Egress broadcast byte count
415 * @page_2: Page_2 statistics structure
416 * @page_2.ingress_filtered_frames: Ingress filtered frame count
417 * @page_2.ingress_discarded_frames: Ingress discarded frame count
418 * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
419 *	lack of buffers
420 * @page_2.egress_discarded_frames: Egress discarded frame count
421 * @page_2.egress_confirmed_frames: Egress confirmed frame count
422 * @page3: Page_3 statistics structure
423 * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
424 *	dequeued from egress FQs
425 * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
426 *	dequeued from egress FQs
427 * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
428 *	egress frames whose enqueue was rejected
429 * @page_3.egress_reject_frames: Cumulative count of the number of egress
430 *	frames whose enqueue was rejected
431 * @page_4: Page_4 statistics structure: congestion points
432 * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
433 * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
434 * @page_5: Page_5 statistics structure: policer
435 * @page_5.policer_cnt_red: NUmber of red colored frames
436 * @page_5.policer_cnt_yellow: number of yellow colored frames
437 * @page_5.policer_cnt_green: number of green colored frames
438 * @page_5.policer_cnt_re_red: number of recolored red frames
439 * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
440 * @page_6: Page_6 statistics structure
441 * @page_6.tx_pending_frames: total number of frames pending in egress FQs
442 * @raw: raw statistics structure, used to index counters
443 */
444union dpni_statistics {
445	struct {
446		u64 ingress_all_frames;
447		u64 ingress_all_bytes;
448		u64 ingress_multicast_frames;
449		u64 ingress_multicast_bytes;
450		u64 ingress_broadcast_frames;
451		u64 ingress_broadcast_bytes;
452	} page_0;
453	struct {
454		u64 egress_all_frames;
455		u64 egress_all_bytes;
456		u64 egress_multicast_frames;
457		u64 egress_multicast_bytes;
458		u64 egress_broadcast_frames;
459		u64 egress_broadcast_bytes;
460	} page_1;
461	struct {
462		u64 ingress_filtered_frames;
463		u64 ingress_discarded_frames;
464		u64 ingress_nobuffer_discards;
465		u64 egress_discarded_frames;
466		u64 egress_confirmed_frames;
467	} page_2;
468	struct {
469		u64 egress_dequeue_bytes;
470		u64 egress_dequeue_frames;
471		u64 egress_reject_bytes;
472		u64 egress_reject_frames;
473	} page_3;
474	struct {
475		u64 cgr_reject_frames;
476		u64 cgr_reject_bytes;
477	} page_4;
478	struct {
479		u64 policer_cnt_red;
480		u64 policer_cnt_yellow;
481		u64 policer_cnt_green;
482		u64 policer_cnt_re_red;
483		u64 policer_cnt_re_yellow;
484	} page_5;
485	struct {
486		u64 tx_pending_frames;
487	} page_6;
488	struct {
489		u64 counter[DPNI_STATISTICS_CNT];
490	} raw;
491};
492
493int dpni_get_statistics(struct fsl_mc_io	*mc_io,
494			u32			cmd_flags,
495			u16			token,
496			u8			page,
497			union dpni_statistics	*stat);
498
499/**
500 * Enable auto-negotiation
501 */
502#define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
503/**
504 * Enable half-duplex mode
505 */
506#define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
507/**
508 * Enable pause frames
509 */
510#define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
511/**
512 * Enable a-symmetric pause frames
513 */
514#define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
 
515
516/**
517 * struct - Structure representing DPNI link configuration
518 * @rate: Rate
519 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
520 */
521struct dpni_link_cfg {
522	u32 rate;
523	u64 options;
524};
525
526int dpni_set_link_cfg(struct fsl_mc_io			*mc_io,
527		      u32				cmd_flags,
528		      u16				token,
529		      const struct dpni_link_cfg	*cfg);
530
531int dpni_get_link_cfg(struct fsl_mc_io			*mc_io,
532		      u32				cmd_flags,
533		      u16				token,
534		      struct dpni_link_cfg		*cfg);
535
536/**
537 * struct dpni_link_state - Structure representing DPNI link state
538 * @rate: Rate
539 * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
540 * @up: Link state; '0' for down, '1' for up
541 */
542struct dpni_link_state {
543	u32	rate;
544	u64	options;
545	int	up;
546};
547
548int dpni_get_link_state(struct fsl_mc_io	*mc_io,
549			u32			cmd_flags,
550			u16			token,
551			struct dpni_link_state	*state);
552
553int dpni_set_max_frame_length(struct fsl_mc_io	*mc_io,
554			      u32		cmd_flags,
555			      u16		token,
556			      u16		max_frame_length);
557
558int dpni_get_max_frame_length(struct fsl_mc_io	*mc_io,
559			      u32		cmd_flags,
560			      u16		token,
561			      u16		*max_frame_length);
562
563int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
564			       u32		cmd_flags,
565			       u16		token,
566			       int		en);
567
568int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
569			       u32		cmd_flags,
570			       u16		token,
571			       int		*en);
572
573int dpni_set_unicast_promisc(struct fsl_mc_io	*mc_io,
574			     u32		cmd_flags,
575			     u16		token,
576			     int		en);
577
578int dpni_get_unicast_promisc(struct fsl_mc_io	*mc_io,
579			     u32		cmd_flags,
580			     u16		token,
581			     int		*en);
582
583int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
584			      u32		cmd_flags,
585			      u16		token,
586			      const u8		mac_addr[6]);
587
588int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
589			      u32		cmd_flags,
590			      u16		token,
591			      u8		mac_addr[6]);
592
593int dpni_get_port_mac_addr(struct fsl_mc_io	*mc_io,
594			   u32			cm_flags,
595			   u16			token,
596			   u8			mac_addr[6]);
597
598int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
599		      u32		cmd_flags,
600		      u16		token,
601		      const u8		mac_addr[6]);
602
603int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
604			 u32			cmd_flags,
605			 u16			token,
606			 const u8		mac_addr[6]);
607
608int dpni_clear_mac_filters(struct fsl_mc_io	*mc_io,
609			   u32			cmd_flags,
610			   u16			token,
611			   int			unicast,
612			   int			multicast);
613
614/**
615 * enum dpni_dist_mode - DPNI distribution mode
616 * @DPNI_DIST_MODE_NONE: No distribution
617 * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
618 *		the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
619 * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
620 *	 the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
621 */
622enum dpni_dist_mode {
623	DPNI_DIST_MODE_NONE = 0,
624	DPNI_DIST_MODE_HASH = 1,
625	DPNI_DIST_MODE_FS = 2
626};
627
628/**
629 * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
630 * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
631 * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
632 * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
633 */
634enum dpni_fs_miss_action {
635	DPNI_FS_MISS_DROP = 0,
636	DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
637	DPNI_FS_MISS_HASH = 2
638};
639
640/**
641 * struct dpni_fs_tbl_cfg - Flow Steering table configuration
642 * @miss_action: Miss action selection
643 * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
644 */
645struct dpni_fs_tbl_cfg {
646	enum dpni_fs_miss_action	miss_action;
647	u16				default_flow_id;
648};
649
650int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
651			 u8 *key_cfg_buf);
652
653/**
654 * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
655 * @dist_size: Set the distribution size;
656 *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
657 *	112,128,192,224,256,384,448,512,768,896,1024
658 * @dist_mode: Distribution mode
659 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
660 *		the extractions to be used for the distribution key by calling
661 *		dpni_prepare_key_cfg() relevant only when
662 *		'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
663 * @fs_cfg: Flow Steering table configuration; only relevant if
664 *		'dist_mode = DPNI_DIST_MODE_FS'
665 */
666struct dpni_rx_tc_dist_cfg {
667	u16			dist_size;
668	enum dpni_dist_mode	dist_mode;
669	u64			key_cfg_iova;
670	struct dpni_fs_tbl_cfg	fs_cfg;
671};
672
673int dpni_set_rx_tc_dist(struct fsl_mc_io			*mc_io,
674			u32					cmd_flags,
675			u16					token,
676			u8					tc_id,
677			const struct dpni_rx_tc_dist_cfg	*cfg);
678
679/**
680 * When used for fs_miss_flow_id in function dpni_set_rx_dist,
681 * will signal to dpni to drop all unclassified frames
682 */
683#define DPNI_FS_MISS_DROP		((uint16_t)-1)
684
685/**
686 * struct dpni_rx_dist_cfg - Rx distribution configuration
687 * @dist_size:	distribution size
688 * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
689 *		the extractions to be used for the distribution key by calling
690 *		dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
691 *		it can be '0'
692 * @enable: enable/disable the distribution.
693 * @tc: TC id for which distribution is set
694 * @fs_miss_flow_id: when packet misses all rules from flow steering table and
695 *		hash is disabled it will be put into this queue id; use
696 *		DPNI_FS_MISS_DROP to drop frames. The value of this field is
697 *		used only when flow steering distribution is enabled and hash
698 *		distribution is disabled
699 */
700struct dpni_rx_dist_cfg {
701	u16 dist_size;
702	u64 key_cfg_iova;
703	u8 enable;
704	u8 tc;
705	u16 fs_miss_flow_id;
706};
707
708int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
709			u32 cmd_flags,
710			u16 token,
711			const struct dpni_rx_dist_cfg *cfg);
712
713int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
714			  u32 cmd_flags,
715			  u16 token,
716			  const struct dpni_rx_dist_cfg *cfg);
717
718/**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719 * enum dpni_dest - DPNI destination types
720 * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
721 *		does not generate FQDAN notifications; user is expected to
722 *		dequeue from the queue based on polling or other user-defined
723 *		method
724 * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
725 *		notifications to the specified DPIO; user is expected to dequeue
726 *		from the queue only after notification is received
727 * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
728 *		FQDAN notifications, but is connected to the specified DPCON
729 *		object; user is expected to dequeue from the DPCON channel
730 */
731enum dpni_dest {
732	DPNI_DEST_NONE = 0,
733	DPNI_DEST_DPIO = 1,
734	DPNI_DEST_DPCON = 2
735};
736
737/**
738 * struct dpni_queue - Queue structure
739 * @destination - Destination structure
740 * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
741 *	Identifies either a DPIO or a DPCON object.
742 *	Not relevant for Tx queues.
743 * @destination.type:	May be one of the following:
744 *	0 - No destination, queue can be manually
745 *		queried, but will not push traffic or
746 *		notifications to a DPIO;
747 *	1 - The destination is a DPIO. When traffic
748 *		becomes available in the queue a FQDAN
749 *		(FQ data available notification) will be
750 *		generated to selected DPIO;
751 *	2 - The destination is a DPCON. The queue is
752 *		associated with a DPCON object for the
753 *		purpose of scheduling between multiple
754 *		queues. The DPCON may be independently
755 *		configured to generate notifications.
756 *		Not relevant for Tx queues.
757 * @destination.hold_active: Hold active, maintains a queue scheduled for longer
758 *	in a DPIO during dequeue to reduce spread of traffic.
759 *	Only relevant if queues are
760 *	not affined to a single DPIO.
761 * @user_context: User data, presented to the user along with any frames
762 *	from this queue. Not relevant for Tx queues.
763 * @flc: FD FLow Context structure
764 * @flc.value: Default FLC value for traffic dequeued from
765 *      this queue.  Please check description of FD
766 *      structure for more information.
767 *      Note that FLC values set using dpni_add_fs_entry,
768 *      if any, take precedence over values per queue.
769 * @flc.stash_control: Boolean, indicates whether the 6 lowest
770 *      - significant bits are used for stash control.
771 *      significant bits are used for stash control.  If set, the 6
772 *      least significant bits in value are interpreted as follows:
773 *      - bits 0-1: indicates the number of 64 byte units of context
774 *      that are stashed.  FLC value is interpreted as a memory address
775 *      in this case, excluding the 6 LS bits.
776 *      - bits 2-3: indicates the number of 64 byte units of frame
777 *      annotation to be stashed.  Annotation is placed at FD[ADDR].
778 *      - bits 4-5: indicates the number of 64 byte units of frame
779 *      data to be stashed.  Frame data is placed at FD[ADDR] +
780 *      FD[OFFSET].
781 *      For more details check the Frame Descriptor section in the
782 *      hardware documentation.
783 */
784struct dpni_queue {
785	struct {
786		u16 id;
787		enum dpni_dest type;
788		char hold_active;
789		u8 priority;
790	} destination;
791	u64 user_context;
792	struct {
793		u64 value;
794		char stash_control;
795	} flc;
796};
797
798/**
799 * struct dpni_queue_id - Queue identification, used for enqueue commands
800 *			or queue control
801 * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
802 * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
803 *		for Tx queues.
804 */
805struct dpni_queue_id {
806	u32 fqid;
807	u16 qdbin;
808};
809
810/**
811 * Set User Context
812 */
813#define DPNI_QUEUE_OPT_USER_CTX		0x00000001
814#define DPNI_QUEUE_OPT_DEST		0x00000002
815#define DPNI_QUEUE_OPT_FLC		0x00000004
816#define DPNI_QUEUE_OPT_HOLD_ACTIVE	0x00000008
817
818int dpni_set_queue(struct fsl_mc_io	*mc_io,
819		   u32			cmd_flags,
820		   u16			token,
821		   enum dpni_queue_type	qtype,
822		   u8			tc,
823		   u8			index,
824		   u8			options,
825		   const struct dpni_queue *queue);
826
827int dpni_get_queue(struct fsl_mc_io	*mc_io,
828		   u32			cmd_flags,
829		   u16			token,
830		   enum dpni_queue_type	qtype,
831		   u8			tc,
832		   u8			index,
833		   struct dpni_queue	*queue,
834		   struct dpni_queue_id	*qid);
835
836/**
837 * enum dpni_congestion_unit - DPNI congestion units
838 * @DPNI_CONGESTION_UNIT_BYTES: bytes units
839 * @DPNI_CONGESTION_UNIT_FRAMES: frames units
840 */
841enum dpni_congestion_unit {
842	DPNI_CONGESTION_UNIT_BYTES = 0,
843	DPNI_CONGESTION_UNIT_FRAMES
844};
845
846/**
847 * enum dpni_congestion_point - Structure representing congestion point
848 * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
849 *		QUEUE_INDEX
850 * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
851 *		define the DPNI this can be either per TC (default) or per
852 *		interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
853 *		QUEUE_INDEX is ignored if this type is used.
854 */
855enum dpni_congestion_point {
856	DPNI_CP_QUEUE,
857	DPNI_CP_GROUP,
858};
859
860/**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
861 * struct dpni_taildrop - Structure representing the taildrop
862 * @enable:	Indicates whether the taildrop is active or not.
863 * @units:	Indicates the unit of THRESHOLD. Queue taildrop only supports
864 *		byte units, this field is ignored and assumed = 0 if
865 *		CONGESTION_POINT is 0.
866 * @threshold:	Threshold value, in units identified by UNITS field. Value 0
867 *		cannot be used as a valid taildrop threshold, THRESHOLD must
868 *		be > 0 if the taildrop is enabled.
869 */
870struct dpni_taildrop {
871	char enable;
872	enum dpni_congestion_unit units;
873	u32 threshold;
874};
875
876int dpni_set_taildrop(struct fsl_mc_io *mc_io,
877		      u32 cmd_flags,
878		      u16 token,
879		      enum dpni_congestion_point cg_point,
880		      enum dpni_queue_type q_type,
881		      u8 tc,
882		      u8 q_index,
883		      struct dpni_taildrop *taildrop);
884
885int dpni_get_taildrop(struct fsl_mc_io *mc_io,
886		      u32 cmd_flags,
887		      u16 token,
888		      enum dpni_congestion_point cg_point,
889		      enum dpni_queue_type q_type,
890		      u8 tc,
891		      u8 q_index,
892		      struct dpni_taildrop *taildrop);
893
894/**
895 * struct dpni_rule_cfg - Rule configuration for table lookup
896 * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
897 * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
898 * @key_size: key and mask size (in bytes)
899 */
900struct dpni_rule_cfg {
901	u64	key_iova;
902	u64	mask_iova;
903	u8	key_size;
904};
905
906/**
907 * Discard matching traffic. If set, this takes precedence over any other
908 * configuration and matching traffic is always discarded.
 
909 */
910 #define DPNI_FS_OPT_DISCARD            0x1
911
912/**
913 * Set FLC value. If set, flc member of struct dpni_fs_action_cfg is used to
914 * override the FLC value set per queue.
915 * For more details check the Frame Descriptor section in the hardware
916 * documentation.
917 */
918#define DPNI_FS_OPT_SET_FLC            0x2
919
920/**
921 * Indicates whether the 6 lowest significant bits of FLC are used for stash
922 * control. If set, the 6 least significant bits in value are interpreted as
923 * follows:
924 *     - bits 0-1: indicates the number of 64 byte units of context that are
925 *     stashed. FLC value is interpreted as a memory address in this case,
926 *     excluding the 6 LS bits.
927 *     - bits 2-3: indicates the number of 64 byte units of frame annotation
928 *     to be stashed. Annotation is placed at FD[ADDR].
929 *     - bits 4-5: indicates the number of 64 byte units of frame data to be
930 *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
931 * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
932 */
933#define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
934
935/**
936 * struct dpni_fs_action_cfg - Action configuration for table look-up
937 * @flc:	FLC value for traffic matching this rule. Please check the
938 *		Frame Descriptor section in the hardware documentation for
939 *		more information.
940 * @flow_id:	Identifies the Rx queue used for matching traffic. Supported
941 *		values are in range 0 to num_queue-1.
942 * @options:	Any combination of DPNI_FS_OPT_ values.
943 */
944struct dpni_fs_action_cfg {
945	u64 flc;
946	u16 flow_id;
947	u16 options;
948};
949
950int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
951		      u32 cmd_flags,
952		      u16 token,
953		      u8 tc_id,
954		      u16 index,
955		      const struct dpni_rule_cfg *cfg,
956		      const struct dpni_fs_action_cfg *action);
957
958int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
959			 u32 cmd_flags,
960			 u16 token,
961			 u8 tc_id,
962			 const struct dpni_rule_cfg *cfg);
963
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964int dpni_get_api_version(struct fsl_mc_io *mc_io,
965			 u32 cmd_flags,
966			 u16 *major_ver,
967			 u16 *minor_ver);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
968
969#endif /* __FSL_DPNI_H */