On 06/19/2018 09:02 PM, Ferruh Yigit wrote:
DEV_RX_OFFLOAD_KEEP_CRC offload flag added. PMDs that supports keeping
CRC should advertise this offload capability.

DEV_RX_OFFLOAD_CRC_STRIP flag will remain one more release
default behavior in PMDs are to keep the CRC until this flag removed

Until DEV_RX_OFFLOAD_CRC_STRIP flag is removed:
- Setting both KEEP_CRC & CRC_STRIP is INVALID
- Setting only CRC_STRIP PMD should strip the CRC
- Setting only KEEP_CRC PMD should keep the CRC
- Not setting both PMD should keep the CRC

A helper function rte_eth_dev_is_keep_crc() has been added to be able to
change the no flag behavior with minimal changes in PMDs.

The PMDs that doesn't report the DEV_RX_OFFLOAD_KEEP_CRC offload can
remove rte_eth_dev_is_keep_crc() checks next release, related code
commented to help the maintenance task.

And DEV_RX_OFFLOAD_CRC_STRIP has been added to virtual drivers since
they don't use CRC at all, when an application requires this offload
virtual PMDs should not return error.

Signed-off-by: Ferruh Yigit <ferruh.yi...@intel.com>
---

<...>

diff --git a/lib/librte_ethdev/rte_ethdev_driver.h 
b/lib/librte_ethdev/rte_ethdev_driver.h
index c9c825e3f..09a42f8c2 100644
--- a/lib/librte_ethdev/rte_ethdev_driver.h
+++ b/lib/librte_ethdev/rte_ethdev_driver.h
@@ -325,6 +325,26 @@ typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
  int __rte_experimental
  rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t 
ethdev_uninit);
+/**
+ * PMD helper function to check if keeping CRC is requested
+ *
+ * @param rx_offloads
+ *   offloads variable
+ *
+ * @return
+ *   Return positive if keeping CRC is requested,
+ *   zero if stripping CRC is requested
+ */
+static inline int
+rte_eth_dev_is_keep_crc(uint64_t rx_offloads)
+{
+       if (rx_offloads & DEV_RX_OFFLOAD_CRC_STRIP)
+               return 0;
+
+       /* no KEEP_CRC or CRC_STRIP offload flags means keep CRC */
+       return 1;
+}
+
  #ifdef __cplusplus
  }
  #endif

A couple of control questions about the function:
 - shouldn't __rte_experimental be used?
 - if the function remains in the future, it will be a bit asymmetric vs other
   offload flags. Right now it is clear why the function is introduced, but
   it is the question if the function should remain or go away in the future
   (as far as I know no other offload flag has similar function to check).

above things are really minor, ethdev and net/sfc
Acked-by: Andrew Rybchenko <arybche...@solarflare.com>

Reply via email to