Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Use Set RSS key command and Set LUT command to e...
details: https://anonhg.NetBSD.org/src/rev/786142f9b1f2
branches: trunk
changeset: 744756:786142f9b1f2
user: yamaguchi <yamaguchi%NetBSD.org@localhost>
date: Wed Feb 12 06:37:21 2020 +0000
description:
Use Set RSS key command and Set LUT command to enable RSS on X722
diffstat:
sys/dev/pci/if_ixl.c | 177 ++++++++++++++++++++++++++++++++++++++++++-----
sys/dev/pci/if_ixlvar.h | 38 ++++++++++-
2 files changed, 194 insertions(+), 21 deletions(-)
diffs (truncated from 313 to 300 lines):
diff -r a2e95a0c8164 -r 786142f9b1f2 sys/dev/pci/if_ixl.c
--- a/sys/dev/pci/if_ixl.c Wed Feb 12 06:36:19 2020 +0000
+++ b/sys/dev/pci/if_ixl.c Wed Feb 12 06:37:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ixl.c,v 1.40 2020/02/12 06:26:02 yamaguchi Exp $ */
+/* $NetBSD: if_ixl.c,v 1.41 2020/02/12 06:37:21 yamaguchi Exp $ */
/*
* Copyright (c) 2013-2015, Intel Corporation
@@ -656,7 +656,7 @@
uint8_t sc_pf_id;
uint16_t sc_uplink_seid; /* le */
uint16_t sc_downlink_seid; /* le */
- uint16_t sc_vsi_number; /* le */
+ uint16_t sc_vsi_number;
uint16_t sc_vsi_stat_counter_idx;
uint16_t sc_seid;
unsigned int sc_base_queue;
@@ -673,6 +673,7 @@
#define IXL_SC_AQ_FLAG_RXCTL __BIT(0)
#define IXL_SC_AQ_FLAG_NVMLOCK __BIT(1)
#define IXL_SC_AQ_FLAG_NVMREAD __BIT(2)
+#define IXL_SC_AQ_FLAG_RSS __BIT(3)
kmutex_t sc_atq_lock;
kcondvar_t sc_atq_cv;
@@ -3966,6 +3967,7 @@
SET(sc->sc_aq_flags, IXL_SC_AQ_FLAG_NVMLOCK |
IXL_SC_AQ_FLAG_NVMREAD);
SET(sc->sc_aq_flags, IXL_SC_AQ_FLAG_RXCTL);
+ SET(sc->sc_aq_flags, IXL_SC_AQ_FLAG_RSS);
}
#define IXL_API_VER(maj, min) (((uint32_t)(maj) << 16) | (min))
@@ -4515,7 +4517,7 @@
}
reply = (struct ixl_aq_vsi_reply *)iaq.iaq_param;
- sc->sc_vsi_number = reply->vsi_number;
+ sc->sc_vsi_number = le16toh(reply->vsi_number);
data = IXL_DMA_KVA(vsi);
sc->sc_vsi_stat_counter_idx = le16toh(data->stat_counter_idx);
@@ -4624,21 +4626,148 @@
memcpy(buf, rss_seed, cplen);
}
-static void
-ixl_set_rss_key(struct ixl_softc *sc)
+static int
+ixl_set_rss_key(struct ixl_softc *sc, uint8_t *key, size_t keylen)
+{
+ struct ixl_dmamem *idm;
+ struct ixl_atq iatq;
+ struct ixl_aq_desc *iaq;
+ struct ixl_aq_rss_key_param *param;
+ struct ixl_aq_rss_key_data *data;
+ size_t len, datalen, stdlen, extlen;
+ uint16_t vsi_id;
+ int rv;
+
+ memset(&iatq, 0, sizeof(iatq));
+ iaq = &iatq.iatq_desc;
+ idm = &sc->sc_aqbuf;
+
+ datalen = sizeof(*data);
+
+ /*XXX The buf size has to be less than the size of the register */
+ datalen = MIN(IXL_RSS_KEY_SIZE_REG * sizeof(uint32_t), datalen);
+
+ iaq->iaq_flags = htole16(IXL_AQ_BUF | IXL_AQ_RD |
+ (datalen > I40E_AQ_LARGE_BUF ? IXL_AQ_LB : 0));
+ iaq->iaq_opcode = htole16(IXL_AQ_OP_RSS_SET_KEY);
+ iaq->iaq_datalen = htole16(datalen);
+
+ param = (struct ixl_aq_rss_key_param *)iaq->iaq_param;
+ vsi_id = (sc->sc_vsi_number << IXL_AQ_RSSKEY_VSI_ID_SHIFT) |
+ IXL_AQ_RSSKEY_VSI_VALID;
+ param->vsi_id = htole16(vsi_id);
+
+ memset(IXL_DMA_KVA(idm), 0, IXL_DMA_LEN(idm));
+ data = IXL_DMA_KVA(idm);
+
+ len = MIN(keylen, datalen);
+ stdlen = MIN(sizeof(data->standard_rss_key), len);
+ memcpy(data->standard_rss_key, key, stdlen);
+ len = (len > stdlen) ? (len - stdlen) : 0;
+
+ extlen = MIN(sizeof(data->extended_hash_key), len);
+ extlen = (stdlen < keylen) ? 0 : keylen - stdlen;
+ memcpy(data->extended_hash_key, key + stdlen, extlen);
+
+ ixl_aq_dva(iaq, IXL_DMA_DVA(idm));
+
+ bus_dmamap_sync(sc->sc_dmat, IXL_DMA_MAP(idm), 0,
+ IXL_DMA_LEN(idm), BUS_DMASYNC_PREWRITE);
+
+ rv = ixl_atq_exec(sc, &iatq);
+
+ bus_dmamap_sync(sc->sc_dmat, IXL_DMA_MAP(idm), 0,
+ IXL_DMA_LEN(idm), BUS_DMASYNC_POSTWRITE);
+
+ if (rv != 0) {
+ return ETIMEDOUT;
+ }
+
+ if (iaq->iaq_retval != htole16(IXL_AQ_RC_OK)) {
+ return EIO;
+ }
+
+ return 0;
+}
+
+static int
+ixl_set_rss_lut(struct ixl_softc *sc, uint8_t *lut, size_t lutlen)
+{
+ struct ixl_dmamem *idm;
+ struct ixl_atq iatq;
+ struct ixl_aq_desc *iaq;
+ struct ixl_aq_rss_lut_param *param;
+ uint16_t vsi_id;
+ uint8_t *data;
+ size_t dmalen;
+ int rv;
+
+ memset(&iatq, 0, sizeof(iatq));
+ iaq = &iatq.iatq_desc;
+ idm = &sc->sc_aqbuf;
+
+ dmalen = MIN(lutlen, IXL_DMA_LEN(idm));
+
+ iaq->iaq_flags = htole16(IXL_AQ_BUF | IXL_AQ_RD |
+ (dmalen > I40E_AQ_LARGE_BUF ? IXL_AQ_LB : 0));
+ iaq->iaq_opcode = htole16(IXL_AQ_OP_RSS_SET_LUT);
+ iaq->iaq_datalen = htole16(dmalen);
+
+ memset(IXL_DMA_KVA(idm), 0, IXL_DMA_LEN(idm));
+ data = IXL_DMA_KVA(idm);
+ memcpy(data, lut, dmalen);
+ ixl_aq_dva(iaq, IXL_DMA_DVA(idm));
+
+ param = (struct ixl_aq_rss_lut_param *)iaq->iaq_param;
+ vsi_id = (sc->sc_vsi_number << IXL_AQ_RSSLUT_VSI_ID_SHIFT) |
+ IXL_AQ_RSSLUT_VSI_VALID;
+ param->vsi_id = htole16(vsi_id);
+ param->flags = htole16(IXL_AQ_RSSLUT_TABLE_TYPE_PF <<
+ IXL_AQ_RSSLUT_TABLE_TYPE_SHIFT);
+
+ bus_dmamap_sync(sc->sc_dmat, IXL_DMA_MAP(idm), 0,
+ IXL_DMA_LEN(idm), BUS_DMASYNC_PREWRITE);
+
+ rv = ixl_atq_exec(sc, &iatq);
+
+ bus_dmamap_sync(sc->sc_dmat, IXL_DMA_MAP(idm), 0,
+ IXL_DMA_LEN(idm), BUS_DMASYNC_POSTWRITE);
+
+ if (rv != 0) {
+ return ETIMEDOUT;
+ }
+
+ if (iaq->iaq_retval != htole16(IXL_AQ_RC_OK)) {
+ return EIO;
+ }
+
+ return 0;
+}
+
+static int
+ixl_register_rss_key(struct ixl_softc *sc)
{
uint32_t rss_seed[IXL_RSS_KEY_SIZE_REG];
+ int rv;
size_t i;
ixl_get_default_rss_key(rss_seed, sizeof(rss_seed));
- for (i = 0; i < IXL_RSS_KEY_SIZE_REG; i++) {
- ixl_wr_rx_csr(sc, I40E_PFQF_HKEY(i), rss_seed[i]);
- }
+ if (ISSET(sc->sc_aq_flags, IXL_SC_AQ_FLAG_RSS)){
+ rv = ixl_set_rss_key(sc, (uint8_t*)rss_seed,
+ sizeof(rss_seed));
+ } else {
+ rv = 0;
+ for (i = 0; i < IXL_RSS_KEY_SIZE_REG; i++) {
+ ixl_wr_rx_csr(sc, I40E_PFQF_HKEY(i), rss_seed[i]);
+ }
+ }
+
+ return rv;
}
static void
-ixl_set_rss_pctype(struct ixl_softc *sc)
+ixl_register_rss_pctype(struct ixl_softc *sc)
{
uint64_t set_hena = 0;
uint32_t hena0, hena1;
@@ -4658,13 +4787,14 @@
ixl_wr_rx_csr(sc, I40E_PFQF_HENA(1), hena1);
}
-static void
-ixl_set_rss_hlut(struct ixl_softc *sc)
+static int
+ixl_register_rss_hlut(struct ixl_softc *sc)
{
unsigned int qid;
uint8_t hlut_buf[512], lut_mask;
uint32_t *hluts;
size_t i, hluts_num;
+ int rv;
lut_mask = (0x01 << sc->sc_rss_table_entry_width) - 1;
@@ -4673,12 +4803,19 @@
hlut_buf[i] = qid & lut_mask;
}
- hluts = (uint32_t *)hlut_buf;
- hluts_num = sc->sc_rss_table_size >> 2;
- for (i = 0; i < hluts_num; i++) {
- ixl_wr(sc, I40E_PFQF_HLUT(i), hluts[i]);
- }
- ixl_flush(sc);
+ if (ISSET(sc->sc_aq_flags, IXL_SC_AQ_FLAG_RSS)) {
+ rv = ixl_set_rss_lut(sc, hlut_buf, sizeof(hlut_buf));
+ } else {
+ rv = 0;
+ hluts = (uint32_t *)hlut_buf;
+ hluts_num = sc->sc_rss_table_size >> 2;
+ for (i = 0; i < hluts_num; i++) {
+ ixl_wr(sc, I40E_PFQF_HLUT(i), hluts[i]);
+ }
+ ixl_flush(sc);
+ }
+
+ return rv;
}
static void
@@ -4687,9 +4824,9 @@
KASSERT(mutex_owned(&sc->sc_cfg_lock));
- ixl_set_rss_key(sc);
- ixl_set_rss_pctype(sc);
- ixl_set_rss_hlut(sc);
+ ixl_register_rss_key(sc);
+ ixl_register_rss_pctype(sc);
+ ixl_register_rss_hlut(sc);
}
static const struct ixl_phy_type *
diff -r a2e95a0c8164 -r 786142f9b1f2 sys/dev/pci/if_ixlvar.h
--- a/sys/dev/pci/if_ixlvar.h Wed Feb 12 06:36:19 2020 +0000
+++ b/sys/dev/pci/if_ixlvar.h Wed Feb 12 06:37:21 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ixlvar.h,v 1.5 2020/01/31 02:16:26 yamaguchi Exp $ */
+/* $NetBSD: if_ixlvar.h,v 1.6 2020/02/12 06:37:21 yamaguchi Exp $ */
/*
* Copyright (c) 2019 Internet Initiative Japan, Inc.
@@ -139,6 +139,10 @@
#define IXL_AQ_OP_LLDP_START_AGENT 0x0a06
#define IXL_AQ_OP_LLDP_GET_CEE_DCBX 0x0a07
#define IXL_AQ_OP_LLDP_SPECIFIC_AGENT 0x0a09
+#define IXL_AQ_OP_RSS_SET_KEY 0x0b02
+#define IXL_AQ_OP_RSS_SET_LUT 0x0b03
+#define IXL_AQ_OP_RSS_GET_KEY 0x0b04
+#define IXL_AQ_OP_RSS_GET_LUT 0x0b05
struct ixl_aq_mac_addresses {
uint8_t pf_lan[ETHER_ADDR_LEN];
@@ -711,6 +715,38 @@
uint32_t addr_lo;
} __packed __aligned(4);
+struct ixl_aq_rss_key_param {
+ uint16_t vsi_id;
+#define IXL_AQ_RSSKEY_VSI_VALID (0x01 << 15)
+#define IXL_AQ_RSSKEY_VSI_ID_SHIFT 0
+#define IXL_AQ_RSSKEY_VSI_ID_MASK (0x3FF << IXL_RSSKEY_VSI_ID_SHIFT)
+
+ uint8_t reserved[6];
+ uint32_t addr_hi;
+ uint32_t addr_lo;
+} __packed __aligned(8);
+
+struct ixl_aq_rss_key_data {
+ uint8_t standard_rss_key[0x28];
+ uint8_t extended_hash_key[0xc];
+} __packed __aligned(8);
+
+struct ixl_aq_rss_lut_param {
+ uint16_t vsi_id;
+#define IXL_AQ_RSSLUT_VSI_VALID (0x01 << 15)
+#define IXL_AQ_RSSLUT_VSI_ID_SHIFT 0
+#define IXL_AQ_RSSLUT_VSI_ID_MASK (0x03FF << IXL_AQ_RSSLUT_VSI_ID_SHIFT)
+
Home |
Main Index |
Thread Index |
Old Index