bnxt: propagate RSS hash type to the network stack.

RSS hash type will be used to identify the CPU on to which, a receive packet
will be queued.  This patch extracts the "RSS hash type" from the receive
completion and sends it to the stack.

Submitted by:	Venkatkumar Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed by:	shurd
Approved by:	sbruno
MFC after:	1 week
Sponsored by:	Broadcom Limited
Differential Revision:	https://reviews.freebsd.org/D9685
This commit is contained in:
shurd 2017-02-28 02:27:51 +00:00
parent ee4d9d33b4
commit 12f3b86d0d
2 changed files with 41 additions and 14 deletions

View File

@ -92,6 +92,14 @@ __FBSDID("$FreeBSD$");
#define BNXT_MAX_MTU 9000 #define BNXT_MAX_MTU 9000
#define BNXT_RSS_HASH_TYPE_TCPV4 0
#define BNXT_RSS_HASH_TYPE_UDPV4 1
#define BNXT_RSS_HASH_TYPE_IPV4 2
#define BNXT_RSS_HASH_TYPE_TCPV6 3
#define BNXT_RSS_HASH_TYPE_UDPV6 4
#define BNXT_RSS_HASH_TYPE_IPV6 5
#define BNXT_GET_RSS_PROFILE_ID(rss_hash_type) ((rss_hash_type >> 1) & 0x1F)
/* Completion related defines */ /* Completion related defines */
#define CMP_VALID(cmp, v_bit) \ #define CMP_VALID(cmp, v_bit) \
((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == !!(v_bit) ) ((!!(((struct cmpl_base *)(cmp))->info3_v & htole32(CMPL_BASE_V))) == !!(v_bit) )

View File

@ -412,6 +412,37 @@ bnxt_isc_rxd_available(void *sc, uint16_t rxqid, uint32_t idx, int budget)
return avail; return avail;
} }
static void
bnxt_set_rsstype(if_rxd_info_t ri, uint8_t rss_hash_type)
{
uint8_t rss_profile_id;
rss_profile_id = BNXT_GET_RSS_PROFILE_ID(rss_hash_type);
switch (rss_profile_id) {
case BNXT_RSS_HASH_TYPE_TCPV4:
ri->iri_rsstype = M_HASHTYPE_RSS_TCP_IPV4;
break;
case BNXT_RSS_HASH_TYPE_UDPV4:
ri->iri_rsstype = M_HASHTYPE_RSS_UDP_IPV4;
break;
case BNXT_RSS_HASH_TYPE_IPV4:
ri->iri_rsstype = M_HASHTYPE_RSS_IPV4;
break;
case BNXT_RSS_HASH_TYPE_TCPV6:
ri->iri_rsstype = M_HASHTYPE_RSS_TCP_IPV6;
break;
case BNXT_RSS_HASH_TYPE_UDPV6:
ri->iri_rsstype = M_HASHTYPE_RSS_UDP_IPV6;
break;
case BNXT_RSS_HASH_TYPE_IPV6:
ri->iri_rsstype = M_HASHTYPE_RSS_IPV6;
break;
default:
ri->iri_rsstype = M_HASHTYPE_OPAQUE;
break;
}
}
static int static int
bnxt_pkt_get_l2(struct bnxt_softc *softc, if_rxd_info_t ri, bnxt_pkt_get_l2(struct bnxt_softc *softc, if_rxd_info_t ri,
struct bnxt_cp_ring *cpr, uint16_t flags_type) struct bnxt_cp_ring *cpr, uint16_t flags_type)
@ -429,13 +460,7 @@ bnxt_pkt_get_l2(struct bnxt_softc *softc, if_rxd_info_t ri,
/* Extract from the first 16-byte BD */ /* Extract from the first 16-byte BD */
if (flags_type & RX_PKT_CMPL_FLAGS_RSS_VALID) { if (flags_type & RX_PKT_CMPL_FLAGS_RSS_VALID) {
ri->iri_flowid = le32toh(rcp->rss_hash); ri->iri_flowid = le32toh(rcp->rss_hash);
/* bnxt_set_rsstype(ri, rcp->rss_hash_type);
* TODO: Extract something useful from rcp->rss_hash_type
* (undocumented)
* May be documented in the "LSI ES"
* also check the firmware code.
*/
ri->iri_rsstype = M_HASHTYPE_OPAQUE;
} }
else { else {
ri->iri_rsstype = M_HASHTYPE_NONE; ri->iri_rsstype = M_HASHTYPE_NONE;
@ -515,13 +540,7 @@ bnxt_pkt_get_tpa(struct bnxt_softc *softc, if_rxd_info_t ri,
/* Extract from the first 16-byte BD */ /* Extract from the first 16-byte BD */
if (le16toh(tpas->low.flags_type) & RX_TPA_START_CMPL_FLAGS_RSS_VALID) { if (le16toh(tpas->low.flags_type) & RX_TPA_START_CMPL_FLAGS_RSS_VALID) {
ri->iri_flowid = le32toh(tpas->low.rss_hash); ri->iri_flowid = le32toh(tpas->low.rss_hash);
/* bnxt_set_rsstype(ri, tpas->low.rss_hash_type);
* TODO: Extract something useful from tpas->low.rss_hash_type
* (undocumented)
* May be documented in the "LSI ES"
* also check the firmware code.
*/
ri->iri_rsstype = M_HASHTYPE_OPAQUE;
} }
else { else {
ri->iri_rsstype = M_HASHTYPE_NONE; ri->iri_rsstype = M_HASHTYPE_NONE;