mbuf: add new Rx checksum flags
Following discussions in [1] and [2], introduce a new bit to describe the Rx checksum status in mbuf. Before this patch, only one flag was available: PKT_RX_L4_CKSUM_BAD: L4 cksum of RX pkt. is not OK. And same for L3: PKT_RX_IP_CKSUM_BAD: IP cksum of RX pkt. is not OK. This had 2 issues: - it was not possible to differentiate "checksum good" from "checksum unknown". - it was not possible for a virtual driver to say "the checksum in packet may be wrong, but data integrity is valid". This patch tries to solve this issue by having 4 states (2 bits) for the IP and L4 Rx checksums. New values are: - PKT_RX_L4_CKSUM_UNKNOWN: no information about the RX L4 checksum -> the application should verify the checksum by sw - PKT_RX_L4_CKSUM_BAD: the L4 checksum in the packet is wrong -> the application can drop the packet without additional check - PKT_RX_L4_CKSUM_GOOD: the L4 checksum in the packet is valid -> the application can accept the packet without verifying the checksum by sw - PKT_RX_L4_CKSUM_NONE: the L4 checksum is not correct in the packet data, but the integrity of the L4 data is verified. -> the application can process the packet but must not verify the checksum by sw. It has to take care to recalculate the cksum if the packet is transmitted (either by sw or using tx offload) And same for L3 (replace L4 by IP in description above). This commit tries to be compatible with existing applications that only check the existing flag (CKSUM_BAD). [1] http://dpdk.org/ml/archives/dev/2016-May/039920.html [2] http://dpdk.org/ml/archives/dev/2016-June/040007.html Signed-off-by: Olivier Matz <olivier.matz@6wind.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com> Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
This commit is contained in:
parent
c442fed81b
commit
5842289a54
@ -697,8 +697,10 @@ pkt_burst_checksum_forward(struct fwd_stream *fs)
|
||||
rx_ol_flags = m->ol_flags;
|
||||
|
||||
/* Update the L3/L4 checksum error packet statistics */
|
||||
rx_bad_ip_csum += ((rx_ol_flags & PKT_RX_IP_CKSUM_BAD) != 0);
|
||||
rx_bad_l4_csum += ((rx_ol_flags & PKT_RX_L4_CKSUM_BAD) != 0);
|
||||
if ((rx_ol_flags & PKT_RX_IP_CKSUM_MASK) == PKT_RX_IP_CKSUM_BAD)
|
||||
rx_bad_ip_csum += 1;
|
||||
if ((rx_ol_flags & PKT_RX_L4_CKSUM_MASK) == PKT_RX_L4_CKSUM_BAD)
|
||||
rx_bad_l4_csum += 1;
|
||||
|
||||
/* step 1: dissect packet, parsing optional vlan, ip4/ip6, vxlan
|
||||
* and inner headers */
|
||||
|
@ -49,6 +49,9 @@ New Features
|
||||
|
||||
* Added a new function ``rte_raw_cksum_mbuf()`` to process the checksum of
|
||||
data embedded in an mbuf chain.
|
||||
* Added new Rx checksum flags in mbufs to describe more states: unknown,
|
||||
good, bad, or not present (useful for virtual drivers). This modification
|
||||
was done for IP and L4.
|
||||
|
||||
* **Added vhost-user dequeue zero copy support**
|
||||
|
||||
|
@ -309,7 +309,11 @@ const char *rte_get_rx_ol_flag_name(uint64_t mask)
|
||||
case PKT_RX_RSS_HASH: return "PKT_RX_RSS_HASH";
|
||||
case PKT_RX_FDIR: return "PKT_RX_FDIR";
|
||||
case PKT_RX_L4_CKSUM_BAD: return "PKT_RX_L4_CKSUM_BAD";
|
||||
case PKT_RX_L4_CKSUM_GOOD: return "PKT_RX_L4_CKSUM_GOOD";
|
||||
case PKT_RX_L4_CKSUM_NONE: return "PKT_RX_L4_CKSUM_NONE";
|
||||
case PKT_RX_IP_CKSUM_BAD: return "PKT_RX_IP_CKSUM_BAD";
|
||||
case PKT_RX_IP_CKSUM_GOOD: return "PKT_RX_IP_CKSUM_GOOD";
|
||||
case PKT_RX_IP_CKSUM_NONE: return "PKT_RX_IP_CKSUM_NONE";
|
||||
case PKT_RX_EIP_CKSUM_BAD: return "PKT_RX_EIP_CKSUM_BAD";
|
||||
case PKT_RX_VLAN_STRIPPED: return "PKT_RX_VLAN_STRIPPED";
|
||||
case PKT_RX_IEEE1588_PTP: return "PKT_RX_IEEE1588_PTP";
|
||||
@ -333,8 +337,16 @@ rte_get_rx_ol_flag_list(uint64_t mask, char *buf, size_t buflen)
|
||||
{ PKT_RX_VLAN_PKT, PKT_RX_VLAN_PKT, NULL },
|
||||
{ PKT_RX_RSS_HASH, PKT_RX_RSS_HASH, NULL },
|
||||
{ PKT_RX_FDIR, PKT_RX_FDIR, NULL },
|
||||
{ PKT_RX_L4_CKSUM_BAD, PKT_RX_L4_CKSUM_BAD, NULL },
|
||||
{ PKT_RX_IP_CKSUM_BAD, PKT_RX_IP_CKSUM_BAD, NULL },
|
||||
{ PKT_RX_L4_CKSUM_BAD, PKT_RX_L4_CKSUM_MASK, NULL },
|
||||
{ PKT_RX_L4_CKSUM_GOOD, PKT_RX_L4_CKSUM_MASK, NULL },
|
||||
{ PKT_RX_L4_CKSUM_NONE, PKT_RX_L4_CKSUM_MASK, NULL },
|
||||
{ PKT_RX_L4_CKSUM_UNKNOWN, PKT_RX_L4_CKSUM_MASK,
|
||||
"PKT_RX_L4_CKSUM_UNKNOWN" },
|
||||
{ PKT_RX_IP_CKSUM_BAD, PKT_RX_IP_CKSUM_MASK, NULL },
|
||||
{ PKT_RX_IP_CKSUM_GOOD, PKT_RX_IP_CKSUM_MASK, NULL },
|
||||
{ PKT_RX_IP_CKSUM_NONE, PKT_RX_IP_CKSUM_MASK, NULL },
|
||||
{ PKT_RX_IP_CKSUM_UNKNOWN, PKT_RX_IP_CKSUM_MASK,
|
||||
"PKT_RX_IP_CKSUM_UNKNOWN" },
|
||||
{ PKT_RX_EIP_CKSUM_BAD, PKT_RX_EIP_CKSUM_BAD, NULL },
|
||||
{ PKT_RX_VLAN_STRIPPED, PKT_RX_VLAN_STRIPPED, NULL },
|
||||
{ PKT_RX_IEEE1588_PTP, PKT_RX_IEEE1588_PTP, NULL },
|
||||
|
@ -91,8 +91,25 @@ extern "C" {
|
||||
|
||||
#define PKT_RX_RSS_HASH (1ULL << 1) /**< RX packet with RSS hash result. */
|
||||
#define PKT_RX_FDIR (1ULL << 2) /**< RX packet with FDIR match indicate. */
|
||||
#define PKT_RX_L4_CKSUM_BAD (1ULL << 3) /**< L4 cksum of RX pkt. is not OK. */
|
||||
#define PKT_RX_IP_CKSUM_BAD (1ULL << 4) /**< IP cksum of RX pkt. is not OK. */
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* Checking this flag alone is deprecated: check the 2 bits of
|
||||
* PKT_RX_L4_CKSUM_MASK.
|
||||
* This flag was set when the L4 checksum of a packet was detected as
|
||||
* wrong by the hardware.
|
||||
*/
|
||||
#define PKT_RX_L4_CKSUM_BAD (1ULL << 3)
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* Checking this flag alone is deprecated: check the 2 bits of
|
||||
* PKT_RX_IP_CKSUM_MASK.
|
||||
* This flag was set when the IP checksum of a packet was detected as
|
||||
* wrong by the hardware.
|
||||
*/
|
||||
#define PKT_RX_IP_CKSUM_BAD (1ULL << 4)
|
||||
|
||||
#define PKT_RX_EIP_CKSUM_BAD (1ULL << 5) /**< External IP header checksum error. */
|
||||
|
||||
/**
|
||||
@ -102,7 +119,35 @@ extern "C" {
|
||||
*/
|
||||
#define PKT_RX_VLAN_STRIPPED (1ULL << 6)
|
||||
|
||||
/* hole, some bits can be reused here */
|
||||
/**
|
||||
* Mask of bits used to determine the status of RX IP checksum.
|
||||
* - PKT_RX_IP_CKSUM_UNKNOWN: no information about the RX IP checksum
|
||||
* - PKT_RX_IP_CKSUM_BAD: the IP checksum in the packet is wrong
|
||||
* - PKT_RX_IP_CKSUM_GOOD: the IP checksum in the packet is valid
|
||||
* - PKT_RX_IP_CKSUM_NONE: the IP checksum is not correct in the packet
|
||||
* data, but the integrity of the IP header is verified.
|
||||
*/
|
||||
#define PKT_RX_IP_CKSUM_MASK ((1ULL << 4) | (1ULL << 7))
|
||||
|
||||
#define PKT_RX_IP_CKSUM_UNKNOWN 0
|
||||
#define PKT_RX_IP_CKSUM_BAD (1ULL << 4)
|
||||
#define PKT_RX_IP_CKSUM_GOOD (1ULL << 7)
|
||||
#define PKT_RX_IP_CKSUM_NONE ((1ULL << 4) | (1ULL << 7))
|
||||
|
||||
/**
|
||||
* Mask of bits used to determine the status of RX L4 checksum.
|
||||
* - PKT_RX_L4_CKSUM_UNKNOWN: no information about the RX L4 checksum
|
||||
* - PKT_RX_L4_CKSUM_BAD: the L4 checksum in the packet is wrong
|
||||
* - PKT_RX_L4_CKSUM_GOOD: the L4 checksum in the packet is valid
|
||||
* - PKT_RX_L4_CKSUM_NONE: the L4 checksum is not correct in the packet
|
||||
* data, but the integrity of the L4 data is verified.
|
||||
*/
|
||||
#define PKT_RX_L4_CKSUM_MASK ((1ULL << 3) | (1ULL << 8))
|
||||
|
||||
#define PKT_RX_L4_CKSUM_UNKNOWN 0
|
||||
#define PKT_RX_L4_CKSUM_BAD (1ULL << 3)
|
||||
#define PKT_RX_L4_CKSUM_GOOD (1ULL << 8)
|
||||
#define PKT_RX_L4_CKSUM_NONE ((1ULL << 3) | (1ULL << 8))
|
||||
|
||||
#define PKT_RX_IEEE1588_PTP (1ULL << 9) /**< RX IEEE1588 L2 Ethernet PT Packet. */
|
||||
#define PKT_RX_IEEE1588_TMST (1ULL << 10) /**< RX IEEE1588 L2/L4 timestamped packet.*/
|
||||
|
Loading…
Reference in New Issue
Block a user