162306a36Sopenharmony_ci/**********************************************************************
262306a36Sopenharmony_ci * Author: Cavium, Inc.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Contact: support@cavium.com
562306a36Sopenharmony_ci *          Please include "LiquidIO" in the subject.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright (c) 2003-2016 Cavium, Inc.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * This file is free software; you can redistribute it and/or modify
1062306a36Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as
1162306a36Sopenharmony_ci * published by the Free Software Foundation.
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * This file is distributed in the hope that it will be useful, but
1462306a36Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
1562306a36Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
1662306a36Sopenharmony_ci * NONINFRINGEMENT.  See the GNU General Public License for more details.
1762306a36Sopenharmony_ci ***********************************************************************/
1862306a36Sopenharmony_ci/*!  \file  octeon_droq.h
1962306a36Sopenharmony_ci *   \brief Implementation of Octeon Output queues. "Output" is with
2062306a36Sopenharmony_ci *   respect to the Octeon device on the NIC. From this driver's point of
2162306a36Sopenharmony_ci *   view they are ingress queues.
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#ifndef __OCTEON_DROQ_H__
2562306a36Sopenharmony_ci#define __OCTEON_DROQ_H__
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci/* Default number of packets that will be processed in one iteration. */
2862306a36Sopenharmony_ci#define MAX_PACKET_BUDGET 0xFFFFFFFF
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/** Octeon descriptor format.
3162306a36Sopenharmony_ci *  The descriptor ring is made of descriptors which have 2 64-bit values:
3262306a36Sopenharmony_ci *  -# Physical (bus) address of the data buffer.
3362306a36Sopenharmony_ci *  -# Physical (bus) address of a octeon_droq_info structure.
3462306a36Sopenharmony_ci *  The Octeon device DMA's incoming packets and its information at the address
3562306a36Sopenharmony_ci *  given by these descriptor fields.
3662306a36Sopenharmony_ci */
3762306a36Sopenharmony_cistruct octeon_droq_desc {
3862306a36Sopenharmony_ci	/** The buffer pointer */
3962306a36Sopenharmony_ci	u64 buffer_ptr;
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci	/** The Info pointer */
4262306a36Sopenharmony_ci	u64 info_ptr;
4362306a36Sopenharmony_ci};
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define OCT_DROQ_DESC_SIZE    (sizeof(struct octeon_droq_desc))
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci/** Information about packet DMA'ed by Octeon.
4862306a36Sopenharmony_ci *  The format of the information available at Info Pointer after Octeon
4962306a36Sopenharmony_ci *  has posted a packet. Not all descriptors have valid information. Only
5062306a36Sopenharmony_ci *  the Info field of the first descriptor for a packet has information
5162306a36Sopenharmony_ci *  about the packet.
5262306a36Sopenharmony_ci */
5362306a36Sopenharmony_cistruct octeon_droq_info {
5462306a36Sopenharmony_ci	/** The Length of the packet. */
5562306a36Sopenharmony_ci	u64 length;
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci	/** The Output Receive Header. */
5862306a36Sopenharmony_ci	union octeon_rh rh;
5962306a36Sopenharmony_ci};
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci#define OCT_DROQ_INFO_SIZE   (sizeof(struct octeon_droq_info))
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_cistruct octeon_skb_page_info {
6462306a36Sopenharmony_ci	/* DMA address for the page */
6562306a36Sopenharmony_ci	dma_addr_t dma;
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci	/* Page for the rx dma  **/
6862306a36Sopenharmony_ci	struct page *page;
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci	/** which offset into page */
7162306a36Sopenharmony_ci	unsigned int page_offset;
7262306a36Sopenharmony_ci};
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci/** Pointer to data buffer.
7562306a36Sopenharmony_ci *  Driver keeps a pointer to the data buffer that it made available to
7662306a36Sopenharmony_ci *  the Octeon device. Since the descriptor ring keeps physical (bus)
7762306a36Sopenharmony_ci *  addresses, this field is required for the driver to keep track of
7862306a36Sopenharmony_ci *  the virtual address pointers.
7962306a36Sopenharmony_ci */
8062306a36Sopenharmony_cistruct octeon_recv_buffer {
8162306a36Sopenharmony_ci	/** Packet buffer, including metadata. */
8262306a36Sopenharmony_ci	void *buffer;
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci	/** Data in the packet buffer.  */
8562306a36Sopenharmony_ci	u8 *data;
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	/** pg_info **/
8862306a36Sopenharmony_ci	struct octeon_skb_page_info pg_info;
8962306a36Sopenharmony_ci};
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define OCT_DROQ_RECVBUF_SIZE    (sizeof(struct octeon_recv_buffer))
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/** Output Queue statistics. Each output queue has four stats fields. */
9462306a36Sopenharmony_cistruct oct_droq_stats {
9562306a36Sopenharmony_ci	/** Number of packets received in this queue. */
9662306a36Sopenharmony_ci	u64 pkts_received;
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci	/** Bytes received by this queue. */
9962306a36Sopenharmony_ci	u64 bytes_received;
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci	/** Packets dropped due to no dispatch function. */
10262306a36Sopenharmony_ci	u64 dropped_nodispatch;
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci	/** Packets dropped due to no memory available. */
10562306a36Sopenharmony_ci	u64 dropped_nomem;
10662306a36Sopenharmony_ci
10762306a36Sopenharmony_ci	/** Packets dropped due to large number of pkts to process. */
10862306a36Sopenharmony_ci	u64 dropped_toomany;
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci	/** Number of packets  sent to stack from this queue. */
11162306a36Sopenharmony_ci	u64 rx_pkts_received;
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci	/** Number of Bytes sent to stack from this queue. */
11462306a36Sopenharmony_ci	u64 rx_bytes_received;
11562306a36Sopenharmony_ci
11662306a36Sopenharmony_ci	/** Num of Packets dropped due to receive path failures. */
11762306a36Sopenharmony_ci	u64 rx_dropped;
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci	u64 rx_vxlan;
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ci	/** Num of failures of recv_buffer_alloc() */
12262306a36Sopenharmony_ci	u64 rx_alloc_failure;
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci};
12562306a36Sopenharmony_ci
12662306a36Sopenharmony_ci/* The maximum number of buffers that can be dispatched from the
12762306a36Sopenharmony_ci * output/dma queue. Set to 64 assuming 1K buffers in DROQ and the fact that
12862306a36Sopenharmony_ci * max packet size from DROQ is 64K.
12962306a36Sopenharmony_ci */
13062306a36Sopenharmony_ci#define    MAX_RECV_BUFS    64
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci/** Receive Packet format used when dispatching output queue packets
13362306a36Sopenharmony_ci *  with non-raw opcodes.
13462306a36Sopenharmony_ci *  The received packet will be sent to the upper layers using this
13562306a36Sopenharmony_ci *  structure which is passed as a parameter to the dispatch function
13662306a36Sopenharmony_ci */
13762306a36Sopenharmony_cistruct octeon_recv_pkt {
13862306a36Sopenharmony_ci	/**  Number of buffers in this received packet */
13962306a36Sopenharmony_ci	u16 buffer_count;
14062306a36Sopenharmony_ci
14162306a36Sopenharmony_ci	/** Id of the device that is sending the packet up */
14262306a36Sopenharmony_ci	u16 octeon_id;
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci	/** Length of data in the packet buffer */
14562306a36Sopenharmony_ci	u32 length;
14662306a36Sopenharmony_ci
14762306a36Sopenharmony_ci	/** The receive header */
14862306a36Sopenharmony_ci	union octeon_rh rh;
14962306a36Sopenharmony_ci
15062306a36Sopenharmony_ci	/** Pointer to the OS-specific packet buffer */
15162306a36Sopenharmony_ci	void *buffer_ptr[MAX_RECV_BUFS];
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci	/** Size of the buffers pointed to by ptr's in buffer_ptr */
15462306a36Sopenharmony_ci	u32 buffer_size[MAX_RECV_BUFS];
15562306a36Sopenharmony_ci};
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci#define OCT_RECV_PKT_SIZE    (sizeof(struct octeon_recv_pkt))
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci/** The first parameter of a dispatch function.
16062306a36Sopenharmony_ci *  For a raw mode opcode, the driver dispatches with the device
16162306a36Sopenharmony_ci *  pointer in this structure.
16262306a36Sopenharmony_ci *  For non-raw mode opcode, the driver dispatches the recv_pkt
16362306a36Sopenharmony_ci *  created to contain the buffers with data received from Octeon.
16462306a36Sopenharmony_ci *  ---------------------
16562306a36Sopenharmony_ci *  |     *recv_pkt ----|---
16662306a36Sopenharmony_ci *  |-------------------|   |
16762306a36Sopenharmony_ci *  | 0 or more bytes   |   |
16862306a36Sopenharmony_ci *  | reserved by driver|   |
16962306a36Sopenharmony_ci *  |-------------------|<-/
17062306a36Sopenharmony_ci *  | octeon_recv_pkt   |
17162306a36Sopenharmony_ci *  |                   |
17262306a36Sopenharmony_ci *  |___________________|
17362306a36Sopenharmony_ci */
17462306a36Sopenharmony_cistruct octeon_recv_info {
17562306a36Sopenharmony_ci	void *rsvd;
17662306a36Sopenharmony_ci	struct octeon_recv_pkt *recv_pkt;
17762306a36Sopenharmony_ci};
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci#define  OCT_RECV_INFO_SIZE    (sizeof(struct octeon_recv_info))
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci/** Allocate a recv_info structure. The recv_pkt pointer in the recv_info
18262306a36Sopenharmony_ci *  structure is filled in before this call returns.
18362306a36Sopenharmony_ci *  @param extra_bytes - extra bytes to be allocated at the end of the recv info
18462306a36Sopenharmony_ci *                       structure.
18562306a36Sopenharmony_ci *  @return - pointer to a newly allocated recv_info structure.
18662306a36Sopenharmony_ci */
18762306a36Sopenharmony_cistatic inline struct octeon_recv_info *octeon_alloc_recv_info(int extra_bytes)
18862306a36Sopenharmony_ci{
18962306a36Sopenharmony_ci	struct octeon_recv_info *recv_info;
19062306a36Sopenharmony_ci	u8 *buf;
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci	buf = kmalloc(OCT_RECV_PKT_SIZE + OCT_RECV_INFO_SIZE +
19362306a36Sopenharmony_ci		      extra_bytes, GFP_ATOMIC);
19462306a36Sopenharmony_ci	if (!buf)
19562306a36Sopenharmony_ci		return NULL;
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci	recv_info = (struct octeon_recv_info *)buf;
19862306a36Sopenharmony_ci	recv_info->recv_pkt =
19962306a36Sopenharmony_ci		(struct octeon_recv_pkt *)(buf + OCT_RECV_INFO_SIZE);
20062306a36Sopenharmony_ci	recv_info->rsvd = NULL;
20162306a36Sopenharmony_ci	if (extra_bytes)
20262306a36Sopenharmony_ci		recv_info->rsvd = buf + OCT_RECV_INFO_SIZE + OCT_RECV_PKT_SIZE;
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci	return recv_info;
20562306a36Sopenharmony_ci}
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci/** Free a recv_info structure.
20862306a36Sopenharmony_ci *  @param recv_info - Pointer to receive_info to be freed
20962306a36Sopenharmony_ci */
21062306a36Sopenharmony_cistatic inline void octeon_free_recv_info(struct octeon_recv_info *recv_info)
21162306a36Sopenharmony_ci{
21262306a36Sopenharmony_ci	kfree(recv_info);
21362306a36Sopenharmony_ci}
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_citypedef int (*octeon_dispatch_fn_t)(struct octeon_recv_info *, void *);
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ci/** Used by NIC module to register packet handler and to get device
21862306a36Sopenharmony_ci * information for each octeon device.
21962306a36Sopenharmony_ci */
22062306a36Sopenharmony_cistruct octeon_droq_ops {
22162306a36Sopenharmony_ci	/** This registered function will be called by the driver with
22262306a36Sopenharmony_ci	 *  the octeon id, pointer to buffer from droq and length of
22362306a36Sopenharmony_ci	 *  data in the buffer. The receive header gives the port
22462306a36Sopenharmony_ci	 *  number to the caller.  Function pointer is set by caller.
22562306a36Sopenharmony_ci	 */
22662306a36Sopenharmony_ci	void (*fptr)(u32, void *, u32, union octeon_rh *, void *, void *);
22762306a36Sopenharmony_ci	void *farg;
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci	/* This function will be called by the driver for all NAPI related
23062306a36Sopenharmony_ci	 * events. The first param is the octeon id. The second param is the
23162306a36Sopenharmony_ci	 * output queue number. The third is the NAPI event that occurred.
23262306a36Sopenharmony_ci	 */
23362306a36Sopenharmony_ci	void (*napi_fn)(void *);
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ci	u32 poll_mode;
23662306a36Sopenharmony_ci
23762306a36Sopenharmony_ci	/** Flag indicating if the DROQ handler should drop packets that
23862306a36Sopenharmony_ci	 *  it cannot handle in one iteration. Set by caller.
23962306a36Sopenharmony_ci	 */
24062306a36Sopenharmony_ci	u32 drop_on_max;
24162306a36Sopenharmony_ci};
24262306a36Sopenharmony_ci
24362306a36Sopenharmony_ci/** The Descriptor Ring Output Queue structure.
24462306a36Sopenharmony_ci *  This structure has all the information required to implement a
24562306a36Sopenharmony_ci *  Octeon DROQ.
24662306a36Sopenharmony_ci */
24762306a36Sopenharmony_cistruct octeon_droq {
24862306a36Sopenharmony_ci	u32 q_no;
24962306a36Sopenharmony_ci
25062306a36Sopenharmony_ci	u32 pkt_count;
25162306a36Sopenharmony_ci
25262306a36Sopenharmony_ci	struct octeon_droq_ops ops;
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci	struct octeon_device *oct_dev;
25562306a36Sopenharmony_ci
25662306a36Sopenharmony_ci	/** The 8B aligned descriptor ring starts at this address. */
25762306a36Sopenharmony_ci	struct octeon_droq_desc *desc_ring;
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci	/** Index in the ring where the driver should read the next packet */
26062306a36Sopenharmony_ci	u32 read_idx;
26162306a36Sopenharmony_ci
26262306a36Sopenharmony_ci	/** Index in the ring where Octeon will write the next packet */
26362306a36Sopenharmony_ci	u32 write_idx;
26462306a36Sopenharmony_ci
26562306a36Sopenharmony_ci	/** Index in the ring where the driver will refill the descriptor's
26662306a36Sopenharmony_ci	 * buffer
26762306a36Sopenharmony_ci	 */
26862306a36Sopenharmony_ci	u32 refill_idx;
26962306a36Sopenharmony_ci
27062306a36Sopenharmony_ci	/** Packets pending to be processed */
27162306a36Sopenharmony_ci	atomic_t pkts_pending;
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci	/** Number of  descriptors in this ring. */
27462306a36Sopenharmony_ci	u32 max_count;
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci	/** The number of descriptors pending refill. */
27762306a36Sopenharmony_ci	u32 refill_count;
27862306a36Sopenharmony_ci
27962306a36Sopenharmony_ci	u32 pkts_per_intr;
28062306a36Sopenharmony_ci	u32 refill_threshold;
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci	/** The max number of descriptors in DROQ without a buffer.
28362306a36Sopenharmony_ci	 * This field is used to keep track of empty space threshold. If the
28462306a36Sopenharmony_ci	 * refill_count reaches this value, the DROQ cannot accept a max-sized
28562306a36Sopenharmony_ci	 * (64K) packet.
28662306a36Sopenharmony_ci	 */
28762306a36Sopenharmony_ci	u32 max_empty_descs;
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci	/** The receive buffer list. This list has the virtual addresses of the
29062306a36Sopenharmony_ci	 * buffers.
29162306a36Sopenharmony_ci	 */
29262306a36Sopenharmony_ci	struct octeon_recv_buffer *recv_buf_list;
29362306a36Sopenharmony_ci
29462306a36Sopenharmony_ci	/** The size of each buffer pointed by the buffer pointer. */
29562306a36Sopenharmony_ci	u32 buffer_size;
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci	/** Pointer to the mapped packet credit register.
29862306a36Sopenharmony_ci	 * Host writes number of info/buffer ptrs available to this register
29962306a36Sopenharmony_ci	 */
30062306a36Sopenharmony_ci	void  __iomem *pkts_credit_reg;
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ci	/** Pointer to the mapped packet sent register.
30362306a36Sopenharmony_ci	 * Octeon writes the number of packets DMA'ed to host memory
30462306a36Sopenharmony_ci	 * in this register.
30562306a36Sopenharmony_ci	 */
30662306a36Sopenharmony_ci	void __iomem *pkts_sent_reg;
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci	struct list_head dispatch_list;
30962306a36Sopenharmony_ci
31062306a36Sopenharmony_ci	/** Statistics for this DROQ. */
31162306a36Sopenharmony_ci	struct oct_droq_stats stats;
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci	/** DMA mapped address of the DROQ descriptor ring. */
31462306a36Sopenharmony_ci	size_t desc_ring_dma;
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ci	/** application context */
31762306a36Sopenharmony_ci	void *app_ctx;
31862306a36Sopenharmony_ci
31962306a36Sopenharmony_ci	struct napi_struct napi;
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci	u32 cpu_id;
32262306a36Sopenharmony_ci
32362306a36Sopenharmony_ci	call_single_data_t csd;
32462306a36Sopenharmony_ci};
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci#define OCT_DROQ_SIZE   (sizeof(struct octeon_droq))
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_ci/**
32962306a36Sopenharmony_ci *  Allocates space for the descriptor ring for the droq and sets the
33062306a36Sopenharmony_ci *   base addr, num desc etc in Octeon registers.
33162306a36Sopenharmony_ci *
33262306a36Sopenharmony_ci * @param  oct_dev    - pointer to the octeon device structure
33362306a36Sopenharmony_ci * @param  q_no       - droq no. ranges from 0 - 3.
33462306a36Sopenharmony_ci * @param app_ctx     - pointer to application context
33562306a36Sopenharmony_ci * @return Success: 0    Failure: 1
33662306a36Sopenharmony_ci */
33762306a36Sopenharmony_ciint octeon_init_droq(struct octeon_device *oct_dev,
33862306a36Sopenharmony_ci		     u32 q_no,
33962306a36Sopenharmony_ci		     u32 num_descs,
34062306a36Sopenharmony_ci		     u32 desc_size,
34162306a36Sopenharmony_ci		     void *app_ctx);
34262306a36Sopenharmony_ci
34362306a36Sopenharmony_ci/**
34462306a36Sopenharmony_ci *  Frees the space for descriptor ring for the droq.
34562306a36Sopenharmony_ci *
34662306a36Sopenharmony_ci *  @param oct_dev - pointer to the octeon device structure
34762306a36Sopenharmony_ci *  @param q_no    - droq no. ranges from 0 - 3.
34862306a36Sopenharmony_ci *  @return:    Success: 0    Failure: 1
34962306a36Sopenharmony_ci */
35062306a36Sopenharmony_ciint octeon_delete_droq(struct octeon_device *oct_dev, u32 q_no);
35162306a36Sopenharmony_ci
35262306a36Sopenharmony_ci/** Register a change in droq operations. The ops field has a pointer to a
35362306a36Sopenharmony_ci * function which will called by the DROQ handler for all packets arriving
35462306a36Sopenharmony_ci * on output queues given by q_no irrespective of the type of packet.
35562306a36Sopenharmony_ci * The ops field also has a flag which if set tells the DROQ handler to
35662306a36Sopenharmony_ci * drop packets if it receives more than what it can process in one
35762306a36Sopenharmony_ci * invocation of the handler.
35862306a36Sopenharmony_ci * @param oct       - octeon device
35962306a36Sopenharmony_ci * @param q_no      - octeon output queue number (0 <= q_no <= MAX_OCTEON_DROQ-1
36062306a36Sopenharmony_ci * @param ops       - the droq_ops settings for this queue
36162306a36Sopenharmony_ci * @return          - 0 on success, -ENODEV or -EINVAL on error.
36262306a36Sopenharmony_ci */
36362306a36Sopenharmony_ciint
36462306a36Sopenharmony_ciocteon_register_droq_ops(struct octeon_device *oct,
36562306a36Sopenharmony_ci			 u32 q_no,
36662306a36Sopenharmony_ci			 struct octeon_droq_ops *ops);
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci/** Resets the function pointer and flag settings made by
36962306a36Sopenharmony_ci * octeon_register_droq_ops(). After this routine is called, the DROQ handler
37062306a36Sopenharmony_ci * will lookup dispatch function for each arriving packet on the output queue
37162306a36Sopenharmony_ci * given by q_no.
37262306a36Sopenharmony_ci * @param oct       - octeon device
37362306a36Sopenharmony_ci * @param q_no      - octeon output queue number (0 <= q_no <= MAX_OCTEON_DROQ-1
37462306a36Sopenharmony_ci * @return          - 0 on success, -ENODEV or -EINVAL on error.
37562306a36Sopenharmony_ci */
37662306a36Sopenharmony_ciint octeon_unregister_droq_ops(struct octeon_device *oct, u32 q_no);
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ci/**   Register a dispatch function for a opcode/subcode. The driver will call
37962306a36Sopenharmony_ci *    this dispatch function when it receives a packet with the given
38062306a36Sopenharmony_ci *    opcode/subcode in its output queues along with the user specified
38162306a36Sopenharmony_ci *    argument.
38262306a36Sopenharmony_ci *    @param  oct        - the octeon device to register with.
38362306a36Sopenharmony_ci *    @param  opcode     - the opcode for which the dispatch will be registered.
38462306a36Sopenharmony_ci *    @param  subcode    - the subcode for which the dispatch will be registered
38562306a36Sopenharmony_ci *    @param  fn         - the dispatch function.
38662306a36Sopenharmony_ci *    @param  fn_arg     - user specified that will be passed along with the
38762306a36Sopenharmony_ci *                         dispatch function by the driver.
38862306a36Sopenharmony_ci *    @return Success: 0; Failure: 1
38962306a36Sopenharmony_ci */
39062306a36Sopenharmony_ciint octeon_register_dispatch_fn(struct octeon_device *oct,
39162306a36Sopenharmony_ci				u16 opcode,
39262306a36Sopenharmony_ci				u16 subcode,
39362306a36Sopenharmony_ci				octeon_dispatch_fn_t fn, void *fn_arg);
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_civoid *octeon_get_dispatch_arg(struct octeon_device *oct,
39662306a36Sopenharmony_ci			      u16 opcode, u16 subcode);
39762306a36Sopenharmony_ci
39862306a36Sopenharmony_civoid octeon_droq_print_stats(void);
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_ciu32 octeon_droq_check_hw_for_pkts(struct octeon_droq *droq);
40162306a36Sopenharmony_ci
40262306a36Sopenharmony_ciint octeon_create_droq(struct octeon_device *oct, u32 q_no,
40362306a36Sopenharmony_ci		       u32 num_descs, u32 desc_size, void *app_ctx);
40462306a36Sopenharmony_ci
40562306a36Sopenharmony_ciint octeon_droq_process_packets(struct octeon_device *oct,
40662306a36Sopenharmony_ci				struct octeon_droq *droq,
40762306a36Sopenharmony_ci				u32 budget);
40862306a36Sopenharmony_ci
40962306a36Sopenharmony_ciint octeon_droq_process_poll_pkts(struct octeon_device *oct,
41062306a36Sopenharmony_ci				  struct octeon_droq *droq, u32 budget);
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ciint octeon_enable_irq(struct octeon_device *oct, u32 q_no);
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_ciint octeon_retry_droq_refill(struct octeon_droq *droq);
41562306a36Sopenharmony_ci
41662306a36Sopenharmony_ci#endif	/*__OCTEON_DROQ_H__ */
417