diff mbox series

[API-NEXT,v1,3/6] api: pktio: deprecate odp_pktio_mtu

Message ID 1510844412-21931-4-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v1,1/6] api: pktio: add max frame length | expand

Commit Message

Github ODP bot Nov. 16, 2017, 3 p.m. UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


MTU is not a well defined term for link layer maximum receive
and transmit frame sizes. Use odp_pktin_maxlen() and
odp_pktout_maxlen() instead.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 298 (psavol:next-frame-len)
 ** https://github.com/Linaro/odp/pull/298
 ** Patch: https://github.com/Linaro/odp/pull/298.patch
 ** Base sha: d4b364849c4abb4c71e0c5260e1a793ebb8dc97d
 ** Merge commit sha: f65f2a6ea63917fca4366f41eeac436d31acec9f
 **/
 include/odp/api/spec/packet_io.h       | 12 ++++++---
 platform/linux-generic/odp_packet_io.c |  2 +-
 test/validation/api/pktio/pktio.c      | 49 +++++++++++++++++++---------------
 3 files changed, 36 insertions(+), 27 deletions(-)
diff mbox series

Patch

diff --git a/include/odp/api/spec/packet_io.h b/include/odp/api/spec/packet_io.h
index b09c9cfcb..a9a39a641 100644
--- a/include/odp/api/spec/packet_io.h
+++ b/include/odp/api/spec/packet_io.h
@@ -30,7 +30,7 @@  extern "C" {
  *
  * Packet IO is the Ingress and Egress interface to ODP processing. It
  * allows manipulation of the interface for setting such attributes as
- * the mtu, mac etc.
+ * number of queues, MAC address etc.
  * Pktio is usually followed by the classifier and a default class COS
  * can be set so that the scheduler may distribute flows. The interface
  * may be used directly in polled mode with odp_pktin_recv() and
@@ -938,14 +938,18 @@  int odp_pktout_send(odp_pktout_queue_t queue, const odp_packet_t packets[],
 		    int num);
 
 /**
- * Return the currently configured MTU value of a packet IO interface.
+ * MTU value of a packet IO interface
  *
- * @param[in] pktio  Packet IO handle.
+ * @deprecated  Use odp_pktin_maxlen() and odp_pktout_maxlen() instead. MTU was
+ * not well defined. There may be difference between MTU and maximum frame
+ * length values.
+ *
+ * @param pktio  Packet IO handle.
  *
  * @return MTU value on success
  * @retval 0 on failure
  */
-uint32_t odp_pktio_mtu(odp_pktio_t pktio);
+uint32_t ODP_DEPRECATE(odp_pktio_mtu)(odp_pktio_t pktio);
 
 /**
  * Enable/Disable promiscuous mode on a packet IO interface.
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index cf65e7235..aa6cdb068 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -803,7 +803,7 @@  static inline uint32_t pktio_mtu(odp_pktio_t hdl)
 	return ret;
 }
 
-uint32_t odp_pktio_mtu(odp_pktio_t pktio)
+uint32_t ODP_DEPRECATE(odp_pktio_mtu)(odp_pktio_t pktio)
 {
 	return pktio_mtu(pktio);
 }
diff --git a/test/validation/api/pktio/pktio.c b/test/validation/api/pktio/pktio.c
index 004379cd8..39451de3b 100644
--- a/test/validation/api/pktio/pktio.c
+++ b/test/validation/api/pktio/pktio.c
@@ -617,13 +617,13 @@  static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b,
 
 	if (packet_len == USE_MTU) {
 		odp_pool_capability_t pool_capa;
-		uint32_t mtu;
+		uint32_t maxlen;
 
-		mtu = odp_pktio_mtu(pktio_a->id);
-		if (odp_pktio_mtu(pktio_b->id) < mtu)
-			mtu = odp_pktio_mtu(pktio_b->id);
-		CU_ASSERT_FATAL(mtu > 0);
-		packet_len = mtu;
+		maxlen = odp_pktout_maxlen(pktio_a->id);
+		if (odp_pktout_maxlen(pktio_b->id) < maxlen)
+			maxlen = odp_pktout_maxlen(pktio_b->id);
+		CU_ASSERT_FATAL(maxlen > 0);
+		packet_len = maxlen;
 		if (packet_len > PKT_LEN_MAX)
 			packet_len = PKT_LEN_MAX;
 
@@ -1026,16 +1026,21 @@  void pktio_test_recv_mtu(void)
 void pktio_test_mtu(void)
 {
 	int ret;
-	uint32_t mtu;
+	uint32_t maxlen;
 
 	odp_pktio_t pktio = create_pktio(0, ODP_PKTIN_MODE_SCHED,
 					 ODP_PKTOUT_MODE_DIRECT);
 	CU_ASSERT_FATAL(pktio != ODP_PKTIO_INVALID);
 
-	mtu = odp_pktio_mtu(pktio);
-	CU_ASSERT(mtu > 0);
+	maxlen = odp_pktout_maxlen(pktio);
+	CU_ASSERT(maxlen > 0);
 
-	printf(" %" PRIu32 " ",  mtu);
+	printf(" %" PRIu32 " ",  maxlen);
+
+	maxlen = odp_pktin_maxlen(pktio);
+	CU_ASSERT(maxlen > 0);
+
+	printf(" %" PRIu32 " ",  maxlen);
 
 	ret = odp_pktio_close(pktio);
 	CU_ASSERT(ret == 0);
@@ -1706,14 +1711,14 @@  void pktio_test_start_stop(void)
 
 /*
  * This is a pre-condition check that the pktio_test_send_failure()
- * test case can be run. If the TX interface MTU is larger that the
+ * test case can be run. If the TX interface max frame len is larger that the
  * biggest packet we can allocate then the test won't be able to
- * attempt to send packets larger than the MTU, so skip the test.
+ * attempt to send packets larger than the max len, so skip the test.
  */
 int pktio_check_send_failure(void)
 {
 	odp_pktio_t pktio_tx;
-	uint32_t mtu;
+	uint32_t maxlen;
 	odp_pktio_param_t pktio_param;
 	int iface_idx = 0;
 	const char *iface = iface_name[iface_idx];
@@ -1734,14 +1739,14 @@  int pktio_check_send_failure(void)
 		return ODP_TEST_INACTIVE;
 	}
 
-	/* read the MTU from the transmit interface */
-	mtu = odp_pktio_mtu(pktio_tx);
+	/* read the maxlen from the transmit interface */
+	maxlen = odp_pktout_maxlen(pktio_tx);
 
 	odp_pktio_close(pktio_tx);
 
 	/* Failure test supports only single segment */
 	if (pool_capa.pkt.max_seg_len &&
-	    pool_capa.pkt.max_seg_len < mtu + 32)
+	    pool_capa.pkt.max_seg_len < maxlen + 32)
 		return ODP_TEST_INACTIVE;
 
 	return ODP_TEST_ACTIVE;
@@ -1753,7 +1758,7 @@  void pktio_test_send_failure(void)
 	odp_packet_t pkt_tbl[TX_BATCH_LEN];
 	uint32_t pkt_seq[TX_BATCH_LEN];
 	int ret, i, alloc_pkts;
-	uint32_t mtu;
+	uint32_t maxlen;
 	odp_pool_param_t pool_params;
 	odp_pool_t pkt_pool;
 	int long_pkt_idx = TX_BATCH_LEN / 2;
@@ -1770,8 +1775,8 @@  void pktio_test_send_failure(void)
 
 	CU_ASSERT_FATAL(odp_pktout_queue(pktio_tx, &pktout, 1) == 1);
 
-	/* read the MTU from the transmit interface */
-	mtu = odp_pktio_mtu(pktio_tx);
+	/* read maxlen from the transmit interface */
+	maxlen = odp_pktout_maxlen(pktio_tx);
 
 	ret = odp_pktio_start(pktio_tx);
 	CU_ASSERT_FATAL(ret == 0);
@@ -1781,15 +1786,15 @@  void pktio_test_send_failure(void)
 	CU_ASSERT_FATAL(odp_pool_capability(&pool_capa) == 0);
 
 	if (pool_capa.pkt.max_seg_len &&
-	    pool_capa.pkt.max_seg_len < mtu + 32) {
+	    pool_capa.pkt.max_seg_len < maxlen + 32) {
 		CU_FAIL("Max packet seg length is too small.");
 		return;
 	}
 
 	/* configure the pool so that we can generate test packets larger
-	 * than the interface MTU */
+	 * than the interface max transmit length */
 	odp_pool_param_init(&pool_params);
-	pool_params.pkt.len     = mtu + 32;
+	pool_params.pkt.len     = maxlen + 32;
 	pool_params.pkt.seg_len = pool_params.pkt.len;
 	pool_params.pkt.num     = TX_BATCH_LEN + 1;
 	pool_params.type        = ODP_POOL_PACKET;