brintos

brintos / linux-shallow public Read only

0
0
Text · 3.4 KiB · bbafeb5 Raw
127 lines · c
1/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */2/*3 * Copyright(c) 2017 - 2020 Intel Corporation.4 */5 6#ifndef _HFI1_VNIC_H7#define _HFI1_VNIC_H8#include <rdma/opa_vnic.h>9#include "hfi.h"10#include "sdma.h"11 12#define HFI1_VNIC_MAX_TXQ     1613#define HFI1_VNIC_MAX_PAD     1214 15/* L4 header definitions */16#define HFI1_VNIC_L4_HDR_OFFSET  OPA_VNIC_L2_HDR_LEN17 18#define HFI1_VNIC_GET_L4_HDR(data)   \19	(*((u16 *)((u8 *)(data) + HFI1_VNIC_L4_HDR_OFFSET)))20 21#define HFI1_VNIC_GET_VESWID(data)   \22	(HFI1_VNIC_GET_L4_HDR(data) & 0xFFF)23 24/* Service class */25#define HFI1_VNIC_SC_OFFSET_LOW 626#define HFI1_VNIC_SC_OFFSET_HI  727#define HFI1_VNIC_SC_SHIFT      428 29#define HFI1_VNIC_MAX_QUEUE 1630#define HFI1_NUM_VNIC_CTXT 831 32/**33 * struct hfi1_vnic_sdma - VNIC per Tx ring SDMA information34 * @dd - device data pointer35 * @sde - sdma engine36 * @vinfo - vnic info pointer37 * @wait - iowait structure38 * @stx - sdma tx request39 * @state - vnic Tx ring SDMA state40 * @q_idx - vnic Tx queue index41 */42struct hfi1_vnic_sdma {43	struct hfi1_devdata *dd;44	struct sdma_engine  *sde;45	struct hfi1_vnic_vport_info *vinfo;46	struct iowait wait;47	struct sdma_txreq stx;48	unsigned int state;49	u8 q_idx;50	bool pkts_sent;51};52 53/**54 * struct hfi1_vnic_rx_queue - HFI1 VNIC receive queue55 * @idx: queue index56 * @vinfo: pointer to vport information57 * @netdev: network device58 * @napi: netdev napi structure59 * @skbq: queue of received socket buffers60 */61struct hfi1_vnic_rx_queue {62	u8                           idx;63	struct hfi1_vnic_vport_info *vinfo;64	struct net_device           *netdev;65	struct napi_struct           napi;66};67 68/**69 * struct hfi1_vnic_vport_info - HFI1 VNIC virtual port information70 * @dd: device data pointer71 * @netdev: net device pointer72 * @flags: state flags73 * @lock: vport lock74 * @num_tx_q: number of transmit queues75 * @num_rx_q: number of receive queues76 * @vesw_id: virtual switch id77 * @rxq: Array of receive queues78 * @stats: per queue stats79 * @sdma: VNIC SDMA structure per TXQ80 */81struct hfi1_vnic_vport_info {82	struct hfi1_devdata *dd;83	struct net_device   *netdev;84	unsigned long        flags;85 86	/* Lock used around state updates */87	struct mutex         lock;88 89	u8  num_tx_q;90	u8  num_rx_q;91	u16 vesw_id;92	struct hfi1_vnic_rx_queue rxq[HFI1_NUM_VNIC_CTXT];93 94	struct opa_vnic_stats  stats[HFI1_VNIC_MAX_QUEUE];95	struct hfi1_vnic_sdma  sdma[HFI1_VNIC_MAX_TXQ];96};97 98#define v_dbg(format, arg...) \99	netdev_dbg(vinfo->netdev, format, ## arg)100#define v_err(format, arg...) \101	netdev_err(vinfo->netdev, format, ## arg)102#define v_info(format, arg...) \103	netdev_info(vinfo->netdev, format, ## arg)104 105/* vnic hfi1 internal functions */106void hfi1_vnic_setup(struct hfi1_devdata *dd);107int hfi1_vnic_txreq_init(struct hfi1_devdata *dd);108void hfi1_vnic_txreq_deinit(struct hfi1_devdata *dd);109 110void hfi1_vnic_bypass_rcv(struct hfi1_packet *packet);111void hfi1_vnic_sdma_init(struct hfi1_vnic_vport_info *vinfo);112bool hfi1_vnic_sdma_write_avail(struct hfi1_vnic_vport_info *vinfo,113				u8 q_idx);114 115/* vnic rdma netdev operations */116struct net_device *hfi1_vnic_alloc_rn(struct ib_device *device,117				      u32 port_num,118				      enum rdma_netdev_t type,119				      const char *name,120				      unsigned char name_assign_type,121				      void (*setup)(struct net_device *));122int hfi1_vnic_send_dma(struct hfi1_devdata *dd, u8 q_idx,123		       struct hfi1_vnic_vport_info *vinfo,124		       struct sk_buff *skb, u64 pbc, u8 plen);125 126#endif /* _HFI1_VNIC_H */127