2017-02-10 19:19:33 +08:00
|
|
|
/*
|
|
|
|
* Broadcom NetXtreme-E RoCE driver.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016 - 2017, Broadcom. All rights reserved. The term
|
|
|
|
* Broadcom refers to Broadcom Limited and/or its subsidiaries.
|
|
|
|
*
|
|
|
|
* This software is available to you under a choice of one of two
|
|
|
|
* licenses. You may choose to be licensed under the terms of the GNU
|
|
|
|
* General Public License (GPL) Version 2, available from the file
|
|
|
|
* COPYING in the main directory of this source tree, or the
|
|
|
|
* BSD license below:
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS''
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
|
|
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
|
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
|
|
|
|
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Description: Slow Path Operators (header)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __BNXT_RE_H__
|
|
|
|
#define __BNXT_RE_H__
|
|
|
|
#define ROCE_DRV_MODULE_NAME "bnxt_re"
|
|
|
|
|
|
|
|
#define BNXT_RE_DESC "Broadcom NetXtreme-C/E RoCE Driver"
|
2018-01-12 00:52:09 +08:00
|
|
|
#define BNXT_RE_PAGE_SHIFT_4K (12)
|
|
|
|
#define BNXT_RE_PAGE_SHIFT_8K (13)
|
|
|
|
#define BNXT_RE_PAGE_SHIFT_64K (16)
|
|
|
|
#define BNXT_RE_PAGE_SHIFT_2M (21)
|
|
|
|
#define BNXT_RE_PAGE_SHIFT_8M (23)
|
|
|
|
#define BNXT_RE_PAGE_SHIFT_1G (30)
|
2017-02-10 19:19:33 +08:00
|
|
|
|
2018-01-12 00:52:09 +08:00
|
|
|
#define BNXT_RE_PAGE_SIZE_4K BIT(BNXT_RE_PAGE_SHIFT_4K)
|
|
|
|
#define BNXT_RE_PAGE_SIZE_8K BIT(BNXT_RE_PAGE_SHIFT_8K)
|
|
|
|
#define BNXT_RE_PAGE_SIZE_64K BIT(BNXT_RE_PAGE_SHIFT_64K)
|
|
|
|
#define BNXT_RE_PAGE_SIZE_2M BIT(BNXT_RE_PAGE_SHIFT_2M)
|
|
|
|
#define BNXT_RE_PAGE_SIZE_8M BIT(BNXT_RE_PAGE_SHIFT_8M)
|
|
|
|
#define BNXT_RE_PAGE_SIZE_1G BIT(BNXT_RE_PAGE_SHIFT_1G)
|
2017-02-10 19:19:33 +08:00
|
|
|
|
2018-02-21 04:56:27 +08:00
|
|
|
#define BNXT_RE_MAX_MR_SIZE_LOW BIT_ULL(BNXT_RE_PAGE_SHIFT_1G)
|
|
|
|
#define BNXT_RE_MAX_MR_SIZE_HIGH BIT_ULL(39)
|
2018-01-12 00:52:09 +08:00
|
|
|
#define BNXT_RE_MAX_MR_SIZE BNXT_RE_MAX_MR_SIZE_HIGH
|
2017-06-30 03:28:12 +08:00
|
|
|
|
2017-02-10 19:19:33 +08:00
|
|
|
#define BNXT_RE_MAX_QPC_COUNT (64 * 1024)
|
|
|
|
#define BNXT_RE_MAX_MRW_COUNT (64 * 1024)
|
|
|
|
#define BNXT_RE_MAX_SRQC_COUNT (64 * 1024)
|
|
|
|
#define BNXT_RE_MAX_CQ_COUNT (64 * 1024)
|
2018-01-12 00:52:07 +08:00
|
|
|
#define BNXT_RE_MAX_MRW_COUNT_64K (64 * 1024)
|
|
|
|
#define BNXT_RE_MAX_MRW_COUNT_256K (256 * 1024)
|
|
|
|
|
|
|
|
/* Number of MRs to reserve for PF, leaving remainder for VFs */
|
|
|
|
#define BNXT_RE_RESVD_MR_FOR_PF (32 * 1024)
|
|
|
|
#define BNXT_RE_MAX_GID_PER_VF 128
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Percentage of resources of each type reserved for PF.
|
|
|
|
* Remaining resources are divided equally among VFs.
|
|
|
|
* [0, 100]
|
|
|
|
*/
|
|
|
|
#define BNXT_RE_PCT_RSVD_FOR_PF 50
|
2017-02-10 19:19:33 +08:00
|
|
|
|
2017-05-22 18:15:36 +08:00
|
|
|
#define BNXT_RE_UD_QP_HW_STALL 0x400000
|
|
|
|
|
2017-05-22 18:15:40 +08:00
|
|
|
#define BNXT_RE_RQ_WQE_THRESHOLD 32
|
|
|
|
|
2017-06-30 03:28:19 +08:00
|
|
|
/*
|
|
|
|
* Setting the default ack delay value to 16, which means
|
|
|
|
* the default timeout is approx. 260ms(4 usec * 2 ^(timeout))
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define BNXT_RE_DEFAULT_ACK_DELAY 16
|
|
|
|
|
2020-02-16 01:11:01 +08:00
|
|
|
struct bnxt_re_ring_attr {
|
|
|
|
dma_addr_t *dma_arr;
|
|
|
|
int pages;
|
|
|
|
int type;
|
|
|
|
u32 depth;
|
|
|
|
u32 lrid; /* Logical ring id */
|
|
|
|
u8 mode;
|
|
|
|
};
|
|
|
|
|
2017-02-10 19:19:33 +08:00
|
|
|
struct bnxt_re_work {
|
|
|
|
struct work_struct work;
|
|
|
|
unsigned long event;
|
|
|
|
struct bnxt_re_dev *rdev;
|
|
|
|
struct net_device *vlan_dev;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct bnxt_re_sqp_entries {
|
|
|
|
struct bnxt_qplib_sge sge;
|
|
|
|
u64 wrid;
|
|
|
|
/* For storing the actual qp1 cqe */
|
|
|
|
struct bnxt_qplib_cqe cqe;
|
|
|
|
struct bnxt_re_qp *qp1_qp;
|
|
|
|
};
|
|
|
|
|
2020-02-16 01:10:58 +08:00
|
|
|
#define BNXT_RE_MAX_GSI_SQP_ENTRIES 1024
|
|
|
|
struct bnxt_re_gsi_context {
|
|
|
|
struct bnxt_re_qp *gsi_qp;
|
|
|
|
struct bnxt_re_qp *gsi_sqp;
|
|
|
|
struct bnxt_re_ah *gsi_sah;
|
|
|
|
struct bnxt_re_sqp_entries *sqp_tbl;
|
|
|
|
};
|
|
|
|
|
2017-02-10 19:19:33 +08:00
|
|
|
#define BNXT_RE_MIN_MSIX 2
|
2017-08-02 16:46:18 +08:00
|
|
|
#define BNXT_RE_MAX_MSIX 9
|
2017-02-10 19:19:33 +08:00
|
|
|
#define BNXT_RE_AEQ_IDX 0
|
|
|
|
#define BNXT_RE_NQ_IDX 1
|
2019-10-03 13:48:35 +08:00
|
|
|
#define BNXT_RE_GEN_P5_MAX_VF 64
|
2017-02-10 19:19:33 +08:00
|
|
|
|
|
|
|
struct bnxt_re_dev {
|
|
|
|
struct ib_device ibdev;
|
|
|
|
struct list_head list;
|
|
|
|
unsigned long flags;
|
2017-08-31 11:57:32 +08:00
|
|
|
#define BNXT_RE_FLAG_NETDEV_REGISTERED 0
|
|
|
|
#define BNXT_RE_FLAG_GOT_MSIX 2
|
|
|
|
#define BNXT_RE_FLAG_HAVE_L2_REF 3
|
|
|
|
#define BNXT_RE_FLAG_RCFW_CHANNEL_EN 4
|
|
|
|
#define BNXT_RE_FLAG_QOS_WORK_REG 5
|
2018-10-08 18:28:04 +08:00
|
|
|
#define BNXT_RE_FLAG_RESOURCES_ALLOCATED 7
|
|
|
|
#define BNXT_RE_FLAG_RESOURCES_INITIALIZED 8
|
2021-03-17 16:15:42 +08:00
|
|
|
#define BNXT_RE_FLAG_ERR_DEVICE_DETACHED 17
|
2018-01-12 00:52:10 +08:00
|
|
|
#define BNXT_RE_FLAG_ISSUE_ROCE_STATS 29
|
2017-02-10 19:19:33 +08:00
|
|
|
struct net_device *netdev;
|
|
|
|
unsigned int version, major, minor;
|
2020-02-16 01:10:59 +08:00
|
|
|
struct bnxt_qplib_chip_ctx *chip_ctx;
|
2017-02-10 19:19:33 +08:00
|
|
|
struct bnxt_en_dev *en_dev;
|
|
|
|
struct bnxt_msix_entry msix_entries[BNXT_RE_MAX_MSIX];
|
|
|
|
int num_msix;
|
|
|
|
|
|
|
|
int id;
|
|
|
|
|
|
|
|
struct delayed_work worker;
|
|
|
|
u8 cur_prio_map;
|
2020-09-17 17:02:23 +08:00
|
|
|
u16 active_speed;
|
2017-08-31 11:57:33 +08:00
|
|
|
u8 active_width;
|
2017-02-10 19:19:33 +08:00
|
|
|
|
|
|
|
/* FP Notification Queue (CQ & SRQ) */
|
|
|
|
struct tasklet_struct nq_task;
|
|
|
|
|
|
|
|
/* RCFW Channel */
|
|
|
|
struct bnxt_qplib_rcfw rcfw;
|
|
|
|
|
|
|
|
/* NQ */
|
2017-08-02 16:46:18 +08:00
|
|
|
struct bnxt_qplib_nq nq[BNXT_RE_MAX_MSIX];
|
2017-02-10 19:19:33 +08:00
|
|
|
|
|
|
|
/* Device Resources */
|
|
|
|
struct bnxt_qplib_dev_attr dev_attr;
|
|
|
|
struct bnxt_qplib_ctx qplib_ctx;
|
|
|
|
struct bnxt_qplib_res qplib_res;
|
|
|
|
struct bnxt_qplib_dpi dpi_privileged;
|
|
|
|
|
|
|
|
atomic_t qp_count;
|
|
|
|
struct mutex qp_lock; /* protect qp list */
|
|
|
|
struct list_head qp_list;
|
|
|
|
|
|
|
|
atomic_t cq_count;
|
|
|
|
atomic_t srq_count;
|
|
|
|
atomic_t mr_count;
|
|
|
|
atomic_t mw_count;
|
|
|
|
/* Max of 2 lossless traffic class supported per port */
|
|
|
|
u16 cosq[2];
|
|
|
|
|
|
|
|
/* QP for for handling QP1 packets */
|
2020-02-16 01:10:58 +08:00
|
|
|
struct bnxt_re_gsi_context gsi_ctx;
|
2017-08-02 16:46:18 +08:00
|
|
|
atomic_t nq_alloc_cnt;
|
2018-01-12 00:52:07 +08:00
|
|
|
u32 is_virtfn;
|
|
|
|
u32 num_vfs;
|
2018-01-12 00:52:10 +08:00
|
|
|
struct bnxt_qplib_roce_stats stats;
|
2017-02-10 19:19:33 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#define to_bnxt_re_dev(ptr, member) \
|
|
|
|
container_of((ptr), struct bnxt_re_dev, member)
|
|
|
|
|
|
|
|
#define BNXT_RE_ROCE_V1_PACKET 0
|
|
|
|
#define BNXT_RE_ROCEV2_IPV4_PACKET 2
|
|
|
|
#define BNXT_RE_ROCEV2_IPV6_PACKET 3
|
|
|
|
|
|
|
|
static inline struct device *rdev_to_dev(struct bnxt_re_dev *rdev)
|
|
|
|
{
|
|
|
|
if (rdev)
|
|
|
|
return &rdev->ibdev.dev;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|