mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-01-17 03:07:02 +07:00
41a7aa7b80
Configure NIX RX flowkey algorithm configuration to support RSS (receive side scaling). Currently support for only L3/L4 2-tuple and 4-tuple hash of IPv4/v6/TCP/UDP/SCTP is added. HW supports upto 32 different flowkey algorithms which SW can define, this patch defines 9. NPC RX ACTION has to point to one of these flowkey indices for RSS to work. The configuration is dependent on NPC parse result's layer info. So if NPC KPU profile changes suchthat LID/LTYPE values of above said protocols change then this configuration will most likely be effected. Signed-off-by: Sunil Goutham <sgoutham@marvell.com> Signed-off-by: David S. Miller <davem@davemloft.net>
212 lines
4.9 KiB
C
212 lines
4.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0
|
|
* Marvell OcteonTx2 RVU Admin Function driver
|
|
*
|
|
* Copyright (C) 2018 Marvell International Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#ifndef COMMON_H
|
|
#define COMMON_H
|
|
|
|
#include "rvu_struct.h"
|
|
|
|
#define OTX2_ALIGN 128 /* Align to cacheline */
|
|
|
|
#define Q_SIZE_16 0ULL /* 16 entries */
|
|
#define Q_SIZE_64 1ULL /* 64 entries */
|
|
#define Q_SIZE_256 2ULL
|
|
#define Q_SIZE_1K 3ULL
|
|
#define Q_SIZE_4K 4ULL
|
|
#define Q_SIZE_16K 5ULL
|
|
#define Q_SIZE_64K 6ULL
|
|
#define Q_SIZE_256K 7ULL
|
|
#define Q_SIZE_1M 8ULL /* Million entries */
|
|
#define Q_SIZE_MIN Q_SIZE_16
|
|
#define Q_SIZE_MAX Q_SIZE_1M
|
|
|
|
#define Q_COUNT(x) (16ULL << (2 * x))
|
|
#define Q_SIZE(x, n) ((ilog2(x) - (n)) / 2)
|
|
|
|
/* Admin queue info */
|
|
|
|
/* Since we intend to add only one instruction at a time,
|
|
* keep queue size to it's minimum.
|
|
*/
|
|
#define AQ_SIZE Q_SIZE_16
|
|
/* HW head & tail pointer mask */
|
|
#define AQ_PTR_MASK 0xFFFFF
|
|
|
|
struct qmem {
|
|
void *base;
|
|
dma_addr_t iova;
|
|
int alloc_sz;
|
|
u8 entry_sz;
|
|
u8 align;
|
|
u32 qsize;
|
|
};
|
|
|
|
static inline int qmem_alloc(struct device *dev, struct qmem **q,
|
|
int qsize, int entry_sz)
|
|
{
|
|
struct qmem *qmem;
|
|
int aligned_addr;
|
|
|
|
if (!qsize)
|
|
return -EINVAL;
|
|
|
|
*q = devm_kzalloc(dev, sizeof(*qmem), GFP_KERNEL);
|
|
if (!*q)
|
|
return -ENOMEM;
|
|
qmem = *q;
|
|
|
|
qmem->entry_sz = entry_sz;
|
|
qmem->alloc_sz = (qsize * entry_sz) + OTX2_ALIGN;
|
|
qmem->base = dma_zalloc_coherent(dev, qmem->alloc_sz,
|
|
&qmem->iova, GFP_KERNEL);
|
|
if (!qmem->base)
|
|
return -ENOMEM;
|
|
|
|
qmem->qsize = qsize;
|
|
|
|
aligned_addr = ALIGN((u64)qmem->iova, OTX2_ALIGN);
|
|
qmem->align = (aligned_addr - qmem->iova);
|
|
qmem->base += qmem->align;
|
|
qmem->iova += qmem->align;
|
|
return 0;
|
|
}
|
|
|
|
static inline void qmem_free(struct device *dev, struct qmem *qmem)
|
|
{
|
|
if (!qmem)
|
|
return;
|
|
|
|
if (qmem->base)
|
|
dma_free_coherent(dev, qmem->alloc_sz,
|
|
qmem->base - qmem->align,
|
|
qmem->iova - qmem->align);
|
|
devm_kfree(dev, qmem);
|
|
}
|
|
|
|
struct admin_queue {
|
|
struct qmem *inst;
|
|
struct qmem *res;
|
|
spinlock_t lock; /* Serialize inst enqueue from PFs */
|
|
};
|
|
|
|
/* NPA aura count */
|
|
enum npa_aura_sz {
|
|
NPA_AURA_SZ_0,
|
|
NPA_AURA_SZ_128,
|
|
NPA_AURA_SZ_256,
|
|
NPA_AURA_SZ_512,
|
|
NPA_AURA_SZ_1K,
|
|
NPA_AURA_SZ_2K,
|
|
NPA_AURA_SZ_4K,
|
|
NPA_AURA_SZ_8K,
|
|
NPA_AURA_SZ_16K,
|
|
NPA_AURA_SZ_32K,
|
|
NPA_AURA_SZ_64K,
|
|
NPA_AURA_SZ_128K,
|
|
NPA_AURA_SZ_256K,
|
|
NPA_AURA_SZ_512K,
|
|
NPA_AURA_SZ_1M,
|
|
NPA_AURA_SZ_MAX,
|
|
};
|
|
|
|
#define NPA_AURA_COUNT(x) (1ULL << ((x) + 6))
|
|
|
|
/* NPA AQ result structure for init/read/write of aura HW contexts */
|
|
struct npa_aq_aura_res {
|
|
struct npa_aq_res_s res;
|
|
struct npa_aura_s aura_ctx;
|
|
struct npa_aura_s ctx_mask;
|
|
};
|
|
|
|
/* NPA AQ result structure for init/read/write of pool HW contexts */
|
|
struct npa_aq_pool_res {
|
|
struct npa_aq_res_s res;
|
|
struct npa_pool_s pool_ctx;
|
|
struct npa_pool_s ctx_mask;
|
|
};
|
|
|
|
/* NIX Transmit schedulers */
|
|
enum nix_scheduler {
|
|
NIX_TXSCH_LVL_SMQ = 0x0,
|
|
NIX_TXSCH_LVL_MDQ = 0x0,
|
|
NIX_TXSCH_LVL_TL4 = 0x1,
|
|
NIX_TXSCH_LVL_TL3 = 0x2,
|
|
NIX_TXSCH_LVL_TL2 = 0x3,
|
|
NIX_TXSCH_LVL_TL1 = 0x4,
|
|
NIX_TXSCH_LVL_CNT = 0x5,
|
|
};
|
|
|
|
/* NIX RX action operation*/
|
|
#define NIX_RX_ACTIONOP_DROP (0x0ull)
|
|
#define NIX_RX_ACTIONOP_UCAST (0x1ull)
|
|
#define NIX_RX_ACTIONOP_UCAST_IPSEC (0x2ull)
|
|
#define NIX_RX_ACTIONOP_MCAST (0x3ull)
|
|
#define NIX_RX_ACTIONOP_RSS (0x4ull)
|
|
|
|
/* NIX TX action operation*/
|
|
#define NIX_TX_ACTIONOP_DROP (0x0ull)
|
|
#define NIX_TX_ACTIONOP_UCAST_DEFAULT (0x1ull)
|
|
#define NIX_TX_ACTIONOP_UCAST_CHAN (0x2ull)
|
|
#define NIX_TX_ACTIONOP_MCAST (0x3ull)
|
|
#define NIX_TX_ACTIONOP_DROP_VIOL (0x5ull)
|
|
|
|
#define NPC_MCAM_KEY_X1 0
|
|
#define NPC_MCAM_KEY_X2 1
|
|
#define NPC_MCAM_KEY_X4 2
|
|
|
|
#define NIX_INTF_RX 0
|
|
#define NIX_INTF_TX 1
|
|
|
|
#define NIX_INTF_TYPE_CGX 0
|
|
#define NIX_INTF_TYPE_LBK 1
|
|
|
|
#define MAX_LMAC_PKIND 12
|
|
#define NIX_LINK_CGX_LMAC(a, b) (0 + 4 * (a) + (b))
|
|
#define NIX_CHAN_CGX_LMAC_CHX(a, b, c) (0x800 + 0x100 * (a) + 0x10 * (b) + (c))
|
|
|
|
/* NIX LSO format indices.
|
|
* As of now TSO is the only one using, so statically assigning indices.
|
|
*/
|
|
#define NIX_LSO_FORMAT_IDX_TSOV4 0
|
|
#define NIX_LSO_FORMAT_IDX_TSOV6 1
|
|
|
|
/* RSS info */
|
|
#define MAX_RSS_GROUPS 8
|
|
/* Group 0 has to be used in default pkt forwarding MCAM entries
|
|
* reserved for NIXLFs. Groups 1-7 can be used for RSS for ntuple
|
|
* filters.
|
|
*/
|
|
#define DEFAULT_RSS_CONTEXT_GROUP 0
|
|
#define MAX_RSS_INDIR_TBL_SIZE 256 /* 1 << Max adder bits */
|
|
|
|
/* NIX flow tag, key type flags */
|
|
#define FLOW_KEY_TYPE_PORT BIT(0)
|
|
#define FLOW_KEY_TYPE_IPV4 BIT(1)
|
|
#define FLOW_KEY_TYPE_IPV6 BIT(2)
|
|
#define FLOW_KEY_TYPE_TCP BIT(3)
|
|
#define FLOW_KEY_TYPE_UDP BIT(4)
|
|
#define FLOW_KEY_TYPE_SCTP BIT(5)
|
|
|
|
/* NIX flow tag algorithm indices, max is 31 */
|
|
enum {
|
|
FLOW_KEY_ALG_PORT,
|
|
FLOW_KEY_ALG_IP,
|
|
FLOW_KEY_ALG_TCP,
|
|
FLOW_KEY_ALG_UDP,
|
|
FLOW_KEY_ALG_SCTP,
|
|
FLOW_KEY_ALG_TCP_UDP,
|
|
FLOW_KEY_ALG_TCP_SCTP,
|
|
FLOW_KEY_ALG_UDP_SCTP,
|
|
FLOW_KEY_ALG_TCP_UDP_SCTP,
|
|
FLOW_KEY_ALG_MAX,
|
|
};
|
|
|
|
#endif /* COMMON_H */
|