From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH net-next 04/19] iecm: add api_init and controlq init
Date: Fri, 28 Jan 2022 13:09:24 +0100 [thread overview]
Message-ID: <20220128120924.20808-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20220128001009.721392-5-alan.brady@intel.com>
From: Alan Brady <alan.brady@intel.com>
Date: Thu, 27 Jan 2022 16:09:54 -0800
> Initializing device registers is offloaded into function pointers given
> to iecm from the dependent device driver for a given device, as offsets
> can vary wildly. This also adds everything needed to setup and use a
> controlq which uses some of those registers.
>
> At the end of probe we kicked off a hard reset and this implements what's
> needed to handle that reset and continue init.
>
> Signed-off-by: Phani Burra <phani.r.burra@intel.com>
> Signed-off-by: Joshua Hay <joshua.a.hay@intel.com>
> Signed-off-by: Madhu Chittim <madhu.chittim@intel.com>
> Signed-off-by: Pavan Kumar Linga <pavan.kumar.linga@intel.com>
> Signed-off-by: Alan Brady <alan.brady@intel.com>
> ---
> drivers/net/ethernet/intel/iecm/Makefile | 3 +
> .../net/ethernet/intel/iecm/iecm_controlq.c | 649 ++++++++++++++++++
> .../ethernet/intel/iecm/iecm_controlq_setup.c | 175 +++++
> drivers/net/ethernet/intel/iecm/iecm_lib.c | 191 +++++-
> .../net/ethernet/intel/iecm/iecm_virtchnl.c | 172 +++++
> drivers/net/ethernet/intel/include/iecm.h | 52 ++
> .../ethernet/intel/include/iecm_controlq.h | 117 ++++
> .../intel/include/iecm_controlq_api.h | 185 +++++
> drivers/net/ethernet/intel/include/iecm_mem.h | 20 +
> 9 files changed, 1563 insertions(+), 1 deletion(-)
> create mode 100644 drivers/net/ethernet/intel/iecm/iecm_controlq.c
> create mode 100644 drivers/net/ethernet/intel/iecm/iecm_controlq_setup.c
> create mode 100644 drivers/net/ethernet/intel/iecm/iecm_virtchnl.c
> create mode 100644 drivers/net/ethernet/intel/include/iecm_controlq.h
> create mode 100644 drivers/net/ethernet/intel/include/iecm_controlq_api.h
> create mode 100644 drivers/net/ethernet/intel/include/iecm_mem.h
>
--- 8< ---
> diff --git a/drivers/net/ethernet/intel/include/iecm_controlq_api.h b/drivers/net/ethernet/intel/include/iecm_controlq_api.h
> new file mode 100644
> index 000000000000..5f624f005d33
> --- /dev/null
> +++ b/drivers/net/ethernet/intel/include/iecm_controlq_api.h
> @@ -0,0 +1,185 @@
> +/* SPDX-License-Identifier: GPL-2.0-only */
> +/* Copyright (c) 2020, Intel Corporation. */
> +
> +#ifndef _IECM_CONTROLQ_API_H_
> +#define _IECM_CONTROLQ_API_H_
> +
> +#include "iecm_mem.h"
> +
> +struct iecm_hw;
> +
> +/* Used for queue init, response and events */
> +enum iecm_ctlq_type {
> + IECM_CTLQ_TYPE_MAILBOX_TX = 0,
> + IECM_CTLQ_TYPE_MAILBOX_RX = 1,
> + IECM_CTLQ_TYPE_CONFIG_TX = 2,
> + IECM_CTLQ_TYPE_CONFIG_RX = 3,
> + IECM_CTLQ_TYPE_EVENT_RX = 4,
> + IECM_CTLQ_TYPE_RDMA_TX = 5,
> + IECM_CTLQ_TYPE_RDMA_RX = 6,
> + IECM_CTLQ_TYPE_RDMA_COMPL = 7
> +};
> +
> +/* Generic Control Queue Structures */
> +struct iecm_ctlq_reg {
> + /* used for queue tracking */
> + u32 head;
> + u32 tail;
> + /* Below applies only to default mb (if present) */
> + u32 len;
> + u32 bah;
> + u32 bal;
> + u32 len_mask;
> + u32 len_ena_mask;
> + u32 head_mask;
> +};
> +
> +/* Generic queue msg structure */
> +struct iecm_ctlq_msg {
> + u16 vmvf_type; /* represents the source of the message on recv */
> +#define IECM_VMVF_TYPE_VF 0
> +#define IECM_VMVF_TYPE_VM 1
> +#define IECM_VMVF_TYPE_PF 2
> + u16 opcode;
> + u16 data_len; /* data_len = 0 when no payload is attached */
> + union {
> + u16 func_id; /* when sending a message */
> + u16 status; /* when receiving a message */
> + };
> + union {
> + struct {
> + u32 chnl_retval;
> + u32 chnl_opcode;
> + } mbx;
> + } cookie;
One field union? If it will be expanded later, please unionize it
only then.
> + union {
> +#define IECM_DIRECT_CTX_SIZE 16
> +#define IECM_INDIRECT_CTX_SIZE 8
> + /* 16 bytes of context can be provided or 8 bytes of context
> + * plus the address of a DMA buffer
> + */
> + u8 direct[IECM_DIRECT_CTX_SIZE];
> + struct {
> + u8 context[IECM_INDIRECT_CTX_SIZE];
> + struct iecm_dma_mem *payload;
> + } indirect;
> + } ctx;
> +};
> +
> +/* Generic queue info structures */
> +/* MB, CONFIG and EVENT q do not have extended info */
> +struct iecm_ctlq_create_info {
> + enum iecm_ctlq_type type;
> + int id; /* absolute queue offset passed as input
> + * -1 for default mailbox if present
> + */
> + u16 len; /* Queue length passed as input */
> + u16 buf_size; /* buffer size passed as input */
> + u64 base_address; /* output, HPA of the Queue start */
> + struct iecm_ctlq_reg reg; /* registers accessed by ctlqs */
> +
> + int ext_info_size;
> + void *ext_info; /* Specific to q type */
> +};
> +
> +/* Control Queue information */
> +struct iecm_ctlq_info {
> + struct list_head cq_list;
> +
> + enum iecm_ctlq_type cq_type;
> + int q_id;
> + /* control queue lock */
> + struct mutex cq_lock;
> +
> + /* used for interrupt processing */
> + u16 next_to_use;
> + u16 next_to_clean;
> + u16 next_to_post; /* starting descriptor to post buffers
> + * to after recev
> + */
> +
> + struct iecm_dma_mem desc_ring; /* descriptor ring memory
> + * iecm_dma_mem is defined in OSdep.h
> + */
> + union {
> + struct iecm_dma_mem **rx_buff;
> + struct iecm_ctlq_msg **tx_msg;
> + } bi;
> +
> + u16 buf_size; /* queue buffer size */
> + u16 ring_size; /* Number of descriptors */
> + struct iecm_ctlq_reg reg; /* registers accessed by ctlqs */
> +};
> +
> +/* PF/VF mailbox commands */
> +enum iecm_mbx_opc {
> + /* iecm_mbq_opc_send_msg_to_pf:
> + * usage: used by PF or VF to send a message to its CPF
> + * target: RX queue and function ID of parent PF taken from HW
> + */
> + iecm_mbq_opc_send_msg_to_pf = 0x0801,
> +
> + /* iecm_mbq_opc_send_msg_to_vf:
> + * usage: used by PF to send message to a VF
> + * target: VF control queue ID must be specified in descriptor
> + */
> + iecm_mbq_opc_send_msg_to_vf = 0x0802,
> +
> + /* iecm_mbq_opc_send_msg_to_peer_pf:
> + * usage: used by any function to send message to any peer PF
> + * target: RX queue and host of parent PF taken from HW
> + */
> + iecm_mbq_opc_send_msg_to_peer_pf = 0x0803,
> +
> + /* iecm_mbq_opc_send_msg_to_peer_drv:
> + * usage: used by any function to send message to any peer driver
> + * target: RX queue and target host must be specific in descriptor
> + */
> + iecm_mbq_opc_send_msg_to_peer_drv = 0x0804,
> +};
> +
> +/* API support for control queue management */
> +
> +/* Will init all required q including default mb. "q_info" is an array of
> + * create_info structs equal to the number of control queues to be created.
> + */
> +int iecm_ctlq_init(struct iecm_hw *hw, u8 num_q,
> + struct iecm_ctlq_create_info *q_info);
> +
> +/* Allocate and initialize a single control queue, which will be added to the
> + * control queue list; returns a handle to the created control queue
> + */
> +int iecm_ctlq_add(struct iecm_hw *hw,
> + struct iecm_ctlq_create_info *qinfo,
> + struct iecm_ctlq_info **cq);
> +
> +/* Deinitialize and deallocate a single control queue */
> +void iecm_ctlq_remove(struct iecm_hw *hw,
> + struct iecm_ctlq_info *cq);
> +
> +/* Sends messages to HW and will also free the buffer*/
> +int iecm_ctlq_send(struct iecm_hw *hw,
> + struct iecm_ctlq_info *cq,
> + u16 num_q_msg,
> + struct iecm_ctlq_msg q_msg[]);
> +
> +/* Receives messages and called by interrupt handler/polling
> + * initiated by app/process. Also caller is supposed to free the buffers
> + */
> +int iecm_ctlq_recv(struct iecm_ctlq_info *cq, u16 *num_q_msg,
> + struct iecm_ctlq_msg *q_msg);
> +
> +/* Reclaims send descriptors on HW write back */
> +int iecm_ctlq_clean_sq(struct iecm_ctlq_info *cq, u16 *clean_count,
> + struct iecm_ctlq_msg *msg_status[]);
> +
> +/* Indicate RX buffers are done being processed */
> +int iecm_ctlq_post_rx_buffs(struct iecm_hw *hw,
> + struct iecm_ctlq_info *cq,
> + u16 *buff_count,
> + struct iecm_dma_mem **buffs);
> +
> +/* Will destroy all q including the default mb */
> +int iecm_ctlq_deinit(struct iecm_hw *hw);
> +
> +#endif /* _IECM_CONTROLQ_API_H_ */
--- 8< ---
> --
> 2.33.0
Thanks,
Al
next prev parent reply other threads:[~2022-01-28 12:09 UTC|newest]
Thread overview: 83+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 0:09 [Intel-wired-lan] [PATCH net-next 00/19] Add iecm and idpf Alan Brady
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 01/19] virtchnl: Add new virtchnl2 ops Alan Brady
2022-02-02 22:13 ` Brady, Alan
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 02/19] iecm: add basic module init and documentation Alan Brady
2022-01-28 11:56 ` Alexander Lobakin
2022-02-02 22:15 ` Brady, Alan
2022-02-01 19:44 ` Shannon Nelson
2022-02-03 3:08 ` Brady, Alan
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 03/19] iecm: add probe and remove Alan Brady
2022-02-01 20:02 ` Shannon Nelson
2022-02-03 3:13 ` Brady, Alan
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 04/19] iecm: add api_init and controlq init Alan Brady
2022-01-28 12:09 ` Alexander Lobakin [this message]
2022-02-02 22:16 ` Brady, Alan
2022-02-01 21:26 ` Shannon Nelson
2022-02-03 3:24 ` Brady, Alan
2022-02-03 3:40 ` Brady, Alan
2022-02-03 5:26 ` Shannon Nelson
2022-02-03 13:13 ` Alexander Lobakin
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 05/19] iecm: add vport alloc and virtchnl messages Alan Brady
2022-01-28 4:19 ` kernel test robot
2022-01-28 12:39 ` Alexander Lobakin
2022-02-02 22:23 ` Brady, Alan
2022-01-28 12:32 ` Alexander Lobakin
2022-02-02 22:21 ` Brady, Alan
2022-02-03 13:23 ` Alexander Lobakin
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 06/19] iecm: add virtchnl messages for queues Alan Brady
2022-01-28 13:03 ` Alexander Lobakin
2022-02-02 22:48 ` Brady, Alan
2022-02-03 10:08 ` Maciej Fijalkowski
2022-02-03 14:09 ` Alexander Lobakin
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 07/19] iecm: finish virtchnl messages Alan Brady
2022-01-28 13:19 ` Alexander Lobakin
2022-02-02 23:06 ` Brady, Alan
2022-02-03 15:05 ` Alexander Lobakin
2022-02-03 15:16 ` Maciej Fijalkowski
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 08/19] iecm: add interrupts and configure netdev Alan Brady
2022-01-28 13:34 ` Alexander Lobakin
2022-02-02 23:17 ` Brady, Alan
2022-02-03 15:55 ` Alexander Lobakin
2022-01-28 0:09 ` [Intel-wired-lan] [PATCH net-next 09/19] iecm: alloc vport TX resources Alan Brady
2022-02-02 23:45 ` Brady, Alan
2022-02-03 17:56 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 10/19] iecm: alloc vport RX resources Alan Brady
2022-01-28 14:16 ` Alexander Lobakin
2022-02-03 0:13 ` Brady, Alan
2022-02-03 18:29 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 11/19] iecm: add start_xmit and set_rx_mode Alan Brady
2022-01-28 16:35 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 12/19] iecm: finish netdev_ops Alan Brady
2022-01-28 17:06 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 13/19] iecm: implement splitq napi_poll Alan Brady
2022-01-28 5:21 ` kernel test robot
2022-01-28 17:44 ` Alexander Lobakin
2022-02-03 1:15 ` Brady, Alan
2022-01-28 17:38 ` Alexander Lobakin
2022-02-03 1:07 ` Brady, Alan
2022-02-04 11:50 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 14/19] iecm: implement singleq napi_poll Alan Brady
2022-01-28 17:57 ` Alexander Lobakin
2022-02-03 1:45 ` Brady, Alan
2022-02-03 19:05 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 15/19] iecm: implement ethtool callbacks Alan Brady
2022-01-28 18:13 ` Alexander Lobakin
2022-02-03 2:13 ` Brady, Alan
2022-02-03 19:54 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 16/19] iecm: implement flow director Alan Brady
2022-01-28 19:04 ` Alexander Lobakin
2022-02-03 2:41 ` Brady, Alan
2022-02-04 10:08 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 17/19] iecm: implement cloud filters Alan Brady
2022-01-28 19:38 ` Alexander Lobakin
2022-02-03 2:53 ` Brady, Alan
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 18/19] iecm: add advanced rss Alan Brady
2022-01-28 19:53 ` Alexander Lobakin
2022-02-03 2:55 ` Brady, Alan
2022-02-03 10:46 ` Maciej Fijalkowski
2022-02-04 10:22 ` Alexander Lobakin
2022-01-28 0:10 ` [Intel-wired-lan] [PATCH net-next 19/19] idpf: introduce idpf driver Alan Brady
2022-01-28 20:08 ` Alexander Lobakin
2022-02-03 3:07 ` Brady, Alan
2022-02-04 10:35 ` Alexander Lobakin
2022-02-04 12:05 ` [Intel-wired-lan] [PATCH net-next 00/19] Add iecm and idpf Alexander Lobakin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220128120924.20808-1-alexandr.lobakin@intel.com \
--to=alexandr.lobakin@intel.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox