DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 3/9] examples/ipsec-secgw: add AES-GCM support
From: Sergio Gonzalez Monroy @ 2016-09-29 15:44 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch
In-Reply-To: <1475163857-142366-1-git-send-email-sergio.gonzalez.monroy@intel.com>

Add support for AES-GCM (Galois-Counter Mode).

RFC4106: The Use of Galois-Counter Mode (GCM) in IPSec ESP.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 examples/ipsec-secgw/esp.c   | 59 ++++++++++++++++++++++++++++++++++++++------
 examples/ipsec-secgw/ipsec.h |  9 +++++++
 examples/ipsec-secgw/sa.c    | 36 +++++++++++++++++++++------
 3 files changed, 90 insertions(+), 14 deletions(-)

diff --git a/examples/ipsec-secgw/esp.c b/examples/ipsec-secgw/esp.c
index 21b2f02..7ee53da 100644
--- a/examples/ipsec-secgw/esp.c
+++ b/examples/ipsec-secgw/esp.c
@@ -90,6 +90,8 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		sa->iv_len;
 	sym_cop->cipher.data.length = payload_len;
 
+	struct cnt_blk *icb;
+	uint8_t *aad;
 	uint8_t *iv = RTE_PTR_ADD(ip4, ip_hdr_len + sizeof(struct esp_hdr));
 
 	switch (sa->cipher_algo) {
@@ -99,14 +101,41 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		sym_cop->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(m,
 				 ip_hdr_len + sizeof(struct esp_hdr));
 		sym_cop->cipher.iv.length = sa->iv_len;
+		break;
+	case RTE_CRYPTO_CIPHER_AES_GCM:
+		icb = get_cnt_blk(m);
+		icb->salt = sa->salt;
+		memcpy(&icb->iv, iv, 8);
+		icb->cnt = rte_cpu_to_be_32(1);
+		sym_cop->cipher.iv.data = (uint8_t *)icb;
+		sym_cop->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(m,
+			 (uint8_t *)icb - rte_pktmbuf_mtod(m, uint8_t *));
+		sym_cop->cipher.iv.length = 16;
+		break;
+	default:
+		RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
+				sa->cipher_algo);
+		return -EINVAL;
+	}
 
+	switch (sa->auth_algo) {
+	case RTE_CRYPTO_AUTH_NULL:
+	case RTE_CRYPTO_AUTH_SHA1_HMAC:
 		sym_cop->auth.data.offset = ip_hdr_len;
 		sym_cop->auth.data.length = sizeof(struct esp_hdr) +
 			sa->iv_len + payload_len;
 		break;
+	case RTE_CRYPTO_AUTH_AES_GCM:
+		aad = get_aad(m);
+		memcpy(aad, iv - sizeof(struct esp_hdr), 8);
+		sym_cop->auth.aad.data = aad;
+		sym_cop->auth.aad.phys_addr = rte_pktmbuf_mtophys_offset(m,
+				aad - rte_pktmbuf_mtod(m, uint8_t *));
+		sym_cop->auth.aad.length = 8;
+		break;
 	default:
-		RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
-				sa->cipher_algo);
+		RTE_LOG(ERR, IPSEC_ESP, "unsupported auth algorithm %u\n",
+				sa->auth_algo);
 		return -EINVAL;
 	}
 
@@ -291,6 +320,12 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 			sizeof(struct esp_hdr);
 		sym_cop->cipher.data.length = pad_payload_len + sa->iv_len;
 		break;
+	case RTE_CRYPTO_CIPHER_AES_GCM:
+		*iv = sa->seq;
+		sym_cop->cipher.data.offset = ip_hdr_len +
+			sizeof(struct esp_hdr) + sa->iv_len;
+		sym_cop->cipher.data.length = pad_payload_len;
+		break;
 	default:
 		RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
 				sa->cipher_algo);
@@ -312,16 +347,26 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 			 (uint8_t *)icb - rte_pktmbuf_mtod(m, uint8_t *));
 	sym_cop->cipher.iv.length = 16;
 
-	switch (sa->cipher_algo) {
-	case RTE_CRYPTO_CIPHER_NULL:
-	case RTE_CRYPTO_CIPHER_AES_CBC:
+	uint8_t *aad;
+
+	switch (sa->auth_algo) {
+	case RTE_CRYPTO_AUTH_NULL:
+	case RTE_CRYPTO_AUTH_SHA1_HMAC:
 		sym_cop->auth.data.offset = ip_hdr_len;
 		sym_cop->auth.data.length = sizeof(struct esp_hdr) +
 			sa->iv_len + pad_payload_len;
 		break;
+	case RTE_CRYPTO_AUTH_AES_GCM:
+		aad = get_aad(m);
+		memcpy(aad, esp, 8);
+		sym_cop->auth.aad.data = aad;
+		sym_cop->auth.aad.phys_addr = rte_pktmbuf_mtophys_offset(m,
+				aad - rte_pktmbuf_mtod(m, uint8_t *));
+		sym_cop->auth.aad.length = 8;
+		break;
 	default:
-		RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
-				sa->cipher_algo);
+		RTE_LOG(ERR, IPSEC_ESP, "unsupported auth algorithm %u\n",
+				sa->auth_algo);
 		return -EINVAL;
 	}
 
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index ad96782..dbc8c2c 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -113,6 +113,7 @@ struct ipsec_sa {
 	uint16_t cipher_key_len;
 	uint8_t auth_key[MAX_KEY_SIZE];
 	uint16_t auth_key_len;
+	uint16_t aad_len;
 	struct rte_crypto_sym_xform *xforms;
 } __rte_cache_aligned;
 
@@ -194,6 +195,14 @@ get_cnt_blk(struct rte_mbuf *m)
 }
 
 static inline void *
+get_aad(struct rte_mbuf *m)
+{
+	struct ipsec_mbuf_metadata *priv = get_priv(m);
+
+	return &priv->buf[16];
+}
+
+static inline void *
 get_sym_cop(struct rte_crypto_op *cop)
 {
 	return (cop + 1);
diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index ee88802..d5ad5af 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -63,6 +63,8 @@ struct supported_auth_algo {
 	enum rte_crypto_auth_algorithm algo;
 	uint16_t digest_len;
 	uint16_t key_len;
+	uint8_t aad_len;
+	uint8_t key_not_req;
 };
 
 const struct supported_cipher_algo cipher_algos[] = {
@@ -79,6 +81,13 @@ const struct supported_cipher_algo cipher_algos[] = {
 		.iv_len = 16,
 		.block_size = 16,
 		.key_len = 16
+	},
+	{
+		.keyword = "aes-128-gcm",
+		.algo = RTE_CRYPTO_CIPHER_AES_GCM,
+		.iv_len = 8,
+		.block_size = 4,
+		.key_len = 16
 	}
 };
 
@@ -87,13 +96,22 @@ const struct supported_auth_algo auth_algos[] = {
 		.keyword = "null",
 		.algo = RTE_CRYPTO_AUTH_NULL,
 		.digest_len = 0,
-		.key_len = 0
+		.key_len = 0,
+		.key_not_req = 1
 	},
 	{
 		.keyword = "sha1-hmac",
 		.algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
 		.digest_len = 12,
 		.key_len = 20
+	},
+	{
+		.keyword = "aes-128-gcm",
+		.algo = RTE_CRYPTO_AUTH_AES_GCM,
+		.digest_len = 16,
+		.key_len = 16,
+		.aad_len = 8,
+		.key_not_req = 1
 	}
 };
 
@@ -255,8 +273,7 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			rule->iv_len = algo->iv_len;
 			rule->cipher_key_len = algo->key_len;
 
-			/* for NULL algorithm, no cipher key should
-			 * exist */
+			/* for NULL algorithm, no cipher key required */
 			if (rule->cipher_algo == RTE_CRYPTO_CIPHER_NULL) {
 				cipher_algo_p = 1;
 				continue;
@@ -307,9 +324,12 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			rule->auth_algo = algo->algo;
 			rule->auth_key_len = algo->key_len;
 			rule->digest_len = algo->digest_len;
+			rule->aad_len = algo->key_len;
 
-			/* for NULL algorithm, no auth key should exist */
-			if (rule->auth_algo == RTE_CRYPTO_AUTH_NULL) {
+			/* NULL algorithm and combined algos do not
+			 * require auth key
+			 */
+			if (algo->key_not_req) {
 				auth_algo_p = 1;
 				continue;
 			}
@@ -572,7 +592,8 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],
 
 			sa_ctx->xf[idx].a.type = RTE_CRYPTO_SYM_XFORM_AUTH;
 			sa_ctx->xf[idx].a.auth.algo = sa->auth_algo;
-			sa_ctx->xf[idx].a.auth.add_auth_data_length = 0;
+			sa_ctx->xf[idx].a.auth.add_auth_data_length =
+				sa->aad_len;
 			sa_ctx->xf[idx].a.auth.key.data = sa->auth_key;
 			sa_ctx->xf[idx].a.auth.key.length =
 				sa->auth_key_len;
@@ -593,7 +614,8 @@ sa_add_rules(struct sa_ctx *sa_ctx, const struct ipsec_sa entries[],
 
 			sa_ctx->xf[idx].b.type = RTE_CRYPTO_SYM_XFORM_AUTH;
 			sa_ctx->xf[idx].b.auth.algo = sa->auth_algo;
-			sa_ctx->xf[idx].b.auth.add_auth_data_length = 0;
+			sa_ctx->xf[idx].b.auth.add_auth_data_length =
+				sa->aad_len;
 			sa_ctx->xf[idx].b.auth.key.data = sa->auth_key;
 			sa_ctx->xf[idx].b.auth.key.length =
 				sa->auth_key_len;
-- 
2.5.5

^ permalink raw reply related

* [PATCH v3 6/9] examples/ipsec-secgw: add cryptodev queue size macro
From: Sergio Gonzalez Monroy @ 2016-09-29 15:44 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch
In-Reply-To: <1475163857-142366-1-git-send-email-sergio.gonzalez.monroy@intel.com>

Introduce a specific cryptodev queue size macro.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 examples/ipsec-secgw/ipsec-secgw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 9eee96f..5a4c9b7 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -82,6 +82,7 @@
 
 #define NB_MBUF	(32000)
 
+#define CDEV_QUEUE_DESC 2048
 #define CDEV_MAP_ENTRIES 1024
 #define CDEV_MP_NB_OBJS 2048
 #define CDEV_MP_CACHE_SZ 64
@@ -1272,7 +1273,7 @@ cryptodevs_init(void)
 			rte_panic("Failed to initialize crypodev %u\n",
 					cdev_id);
 
-		qp_conf.nb_descriptors = CDEV_MP_NB_OBJS;
+		qp_conf.nb_descriptors = CDEV_QUEUE_DESC;
 		for (qp = 0; qp < dev_conf.nb_queue_pairs; qp++)
 			if (rte_cryptodev_queue_pair_setup(cdev_id, qp,
 						&qp_conf, dev_conf.socket_id))
-- 
2.5.5

^ permalink raw reply related

* [PATCH v3 7/9] examples/ipsec-secgw: initialize sa salt
From: Sergio Gonzalez Monroy @ 2016-09-29 15:44 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch
In-Reply-To: <1475163857-142366-1-git-send-email-sergio.gonzalez.monroy@intel.com>

This patch initializes the salt value used by the following cipher
algorithms:
- CBC: random salt
- GCM/CTR: the key required is 20B, and the last 4B are used as salt.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 examples/ipsec-secgw/sa.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/examples/ipsec-secgw/sa.c b/examples/ipsec-secgw/sa.c
index 00c8cce..9e2c8a9 100644
--- a/examples/ipsec-secgw/sa.c
+++ b/examples/ipsec-secgw/sa.c
@@ -45,6 +45,7 @@
 #include <rte_byteorder.h>
 #include <rte_errno.h>
 #include <rte_ip.h>
+#include <rte_random.h>
 
 #include "ipsec.h"
 #include "esp.h"
@@ -87,14 +88,14 @@ const struct supported_cipher_algo cipher_algos[] = {
 		.algo = RTE_CRYPTO_CIPHER_AES_GCM,
 		.iv_len = 8,
 		.block_size = 4,
-		.key_len = 16
+		.key_len = 20
 	},
 	{
 		.keyword = "aes-128-ctr",
 		.algo = RTE_CRYPTO_CIPHER_AES_CTR,
 		.iv_len = 8,
 		.block_size = 16, /* XXX AESNI MB limition, should be 4 */
-		.key_len = 16
+		.key_len = 20
 	}
 };
 
@@ -116,7 +117,6 @@ const struct supported_auth_algo auth_algos[] = {
 		.keyword = "aes-128-gcm",
 		.algo = RTE_CRYPTO_AUTH_AES_GCM,
 		.digest_len = 16,
-		.key_len = 16,
 		.aad_len = 8,
 		.key_not_req = 1
 	}
@@ -307,6 +307,17 @@ parse_sa_tokens(char **tokens, uint32_t n_tokens,
 			if (status->status < 0)
 				return;
 
+			if (algo->algo == RTE_CRYPTO_CIPHER_AES_CBC)
+				rule->salt = (uint32_t)rte_rand();
+
+			if ((algo->algo == RTE_CRYPTO_CIPHER_AES_CTR) ||
+				(algo->algo == RTE_CRYPTO_CIPHER_AES_GCM)) {
+				key_len -= 4;
+				rule->cipher_key_len = key_len;
+				memcpy(&rule->salt,
+					&rule->cipher_key[key_len], 4);
+			}
+
 			cipher_algo_p = 1;
 			continue;
 		}
-- 
2.5.5

^ permalink raw reply related

* [PATCH v3 1/9] examples/ipsec-secgw: change CBC IV generation
From: Sergio Gonzalez Monroy @ 2016-09-29 15:44 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch
In-Reply-To: <1475163857-142366-1-git-send-email-sergio.gonzalez.monroy@intel.com>

NIST SP800-38A recommends two methods to generate unpredictable IVs
(Initilisation Vector) for CBC mode:
1) Apply the forward function to a nonce (ie. counter)
2) Use a FIPS-approved random number generator

This patch implements the first recommended method by using the forward
function to generate the IV.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 examples/ipsec-secgw/esp.c   | 99 +++++++++++++++++++++++++-------------------
 examples/ipsec-secgw/ipsec.h | 26 +++++++++++-
 2 files changed, 81 insertions(+), 44 deletions(-)

diff --git a/examples/ipsec-secgw/esp.c b/examples/ipsec-secgw/esp.c
index 05caa77..21b2f02 100644
--- a/examples/ipsec-secgw/esp.c
+++ b/examples/ipsec-secgw/esp.c
@@ -50,21 +50,6 @@
 #include "esp.h"
 #include "ipip.h"
 
-static inline void
-random_iv_u64(uint64_t *buf, uint16_t n)
-{
-	uint32_t left = n & 0x7;
-	uint32_t i;
-
-	RTE_ASSERT((n & 0x3) == 0);
-
-	for (i = 0; i < (n >> 3); i++)
-		buf[i] = rte_rand();
-
-	if (left)
-		*((uint32_t *)&buf[i]) = (uint32_t)lrand48();
-}
-
 int
 esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		struct rte_crypto_op *cop)
@@ -98,22 +83,32 @@ esp_inbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		return -EINVAL;
 	}
 
-	sym_cop = (struct rte_crypto_sym_op *)(cop + 1);
+	sym_cop = get_sym_cop(cop);
 
 	sym_cop->m_src = m;
 	sym_cop->cipher.data.offset =  ip_hdr_len + sizeof(struct esp_hdr) +
 		sa->iv_len;
 	sym_cop->cipher.data.length = payload_len;
 
-	sym_cop->cipher.iv.data = rte_pktmbuf_mtod_offset(m, void*,
-			 ip_hdr_len + sizeof(struct esp_hdr));
-	sym_cop->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(m,
-			 ip_hdr_len + sizeof(struct esp_hdr));
-	sym_cop->cipher.iv.length = sa->iv_len;
+	uint8_t *iv = RTE_PTR_ADD(ip4, ip_hdr_len + sizeof(struct esp_hdr));
+
+	switch (sa->cipher_algo) {
+	case RTE_CRYPTO_CIPHER_NULL:
+	case RTE_CRYPTO_CIPHER_AES_CBC:
+		sym_cop->cipher.iv.data = iv;
+		sym_cop->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(m,
+				 ip_hdr_len + sizeof(struct esp_hdr));
+		sym_cop->cipher.iv.length = sa->iv_len;
 
-	sym_cop->auth.data.offset = ip_hdr_len;
-	sym_cop->auth.data.length = sizeof(struct esp_hdr) +
-		sa->iv_len + payload_len;
+		sym_cop->auth.data.offset = ip_hdr_len;
+		sym_cop->auth.data.length = sizeof(struct esp_hdr) +
+			sa->iv_len + payload_len;
+		break;
+	default:
+		RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
+				sa->cipher_algo);
+		return -EINVAL;
+	}
 
 	sym_cop->auth.digest.data = rte_pktmbuf_mtod_offset(m, void*,
 			rte_pktmbuf_pkt_len(m) - sa->digest_len);
@@ -282,10 +277,25 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 
 	sa->seq++;
 	esp->spi = rte_cpu_to_be_32(sa->spi);
-	esp->seq = rte_cpu_to_be_32(sa->seq);
+	esp->seq = rte_cpu_to_be_32((uint32_t)sa->seq);
 
-	if (sa->cipher_algo == RTE_CRYPTO_CIPHER_AES_CBC)
-		random_iv_u64((uint64_t *)(esp + 1), sa->iv_len);
+	uint64_t *iv = (uint64_t *)(esp + 1);
+
+	sym_cop = get_sym_cop(cop);
+	sym_cop->m_src = m;
+	switch (sa->cipher_algo) {
+	case RTE_CRYPTO_CIPHER_NULL:
+	case RTE_CRYPTO_CIPHER_AES_CBC:
+		memset(iv, 0, sa->iv_len);
+		sym_cop->cipher.data.offset = ip_hdr_len +
+			sizeof(struct esp_hdr);
+		sym_cop->cipher.data.length = pad_payload_len + sa->iv_len;
+		break;
+	default:
+		RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
+				sa->cipher_algo);
+		return -EINVAL;
+	}
 
 	/* Fill pad_len using default sequential scheme */
 	for (i = 0; i < pad_len - 2; i++)
@@ -293,22 +303,27 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 	padding[pad_len - 2] = pad_len - 2;
 	padding[pad_len - 1] = nlp;
 
-	sym_cop = (struct rte_crypto_sym_op *)(cop + 1);
-
-	sym_cop->m_src = m;
-	sym_cop->cipher.data.offset = ip_hdr_len + sizeof(struct esp_hdr) +
-			sa->iv_len;
-	sym_cop->cipher.data.length = pad_payload_len;
-
-	sym_cop->cipher.iv.data = rte_pktmbuf_mtod_offset(m, uint8_t *,
-			 ip_hdr_len + sizeof(struct esp_hdr));
+	struct cnt_blk *icb = get_cnt_blk(m);
+	icb->salt = sa->salt;
+	icb->iv = sa->seq;
+	icb->cnt = rte_cpu_to_be_32(1);
+	sym_cop->cipher.iv.data = (uint8_t *)icb;
 	sym_cop->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(m,
-			 ip_hdr_len + sizeof(struct esp_hdr));
-	sym_cop->cipher.iv.length = sa->iv_len;
-
-	sym_cop->auth.data.offset = ip_hdr_len;
-	sym_cop->auth.data.length = sizeof(struct esp_hdr) + sa->iv_len +
-		pad_payload_len;
+			 (uint8_t *)icb - rte_pktmbuf_mtod(m, uint8_t *));
+	sym_cop->cipher.iv.length = 16;
+
+	switch (sa->cipher_algo) {
+	case RTE_CRYPTO_CIPHER_NULL:
+	case RTE_CRYPTO_CIPHER_AES_CBC:
+		sym_cop->auth.data.offset = ip_hdr_len;
+		sym_cop->auth.data.length = sizeof(struct esp_hdr) +
+			sa->iv_len + pad_payload_len;
+		break;
+	default:
+		RTE_LOG(ERR, IPSEC_ESP, "unsupported cipher algorithm %u\n",
+				sa->cipher_algo);
+		return -EINVAL;
+	}
 
 	sym_cop->auth.digest.data = rte_pktmbuf_mtod_offset(m, uint8_t *,
 			rte_pktmbuf_pkt_len(m) - sa->digest_len);
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index 4cc316c..ad96782 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -95,8 +95,9 @@ struct ip_addr {
 struct ipsec_sa {
 	uint32_t spi;
 	uint32_t cdev_id_qp;
+	uint64_t seq;
+	uint32_t salt;
 	struct rte_cryptodev_sym_session *crypto_session;
-	uint32_t seq;
 	enum rte_crypto_cipher_algorithm cipher_algo;
 	enum rte_crypto_auth_algorithm auth_algo;
 	uint16_t digest_len;
@@ -116,10 +117,11 @@ struct ipsec_sa {
 } __rte_cache_aligned;
 
 struct ipsec_mbuf_metadata {
+	uint8_t buf[32];
 	struct ipsec_sa *sa;
 	struct rte_crypto_op cop;
 	struct rte_crypto_sym_op sym_cop;
-};
+} __rte_cache_aligned;
 
 struct cdev_qp {
 	uint16_t id;
@@ -157,6 +159,12 @@ struct socket_ctx {
 	struct rte_mempool *mbuf_pool;
 };
 
+struct cnt_blk {
+	uint32_t salt;
+	uint64_t iv;
+	uint32_t cnt;
+} __attribute__((packed));
+
 uint16_t
 ipsec_inbound(struct ipsec_ctx *ctx, struct rte_mbuf *pkts[],
 		uint16_t nb_pkts, uint16_t len);
@@ -177,6 +185,20 @@ get_priv(struct rte_mbuf *m)
 	return RTE_PTR_ADD(m, sizeof(struct rte_mbuf));
 }
 
+static inline void *
+get_cnt_blk(struct rte_mbuf *m)
+{
+	struct ipsec_mbuf_metadata *priv = get_priv(m);
+
+	return &priv->buf[0];
+}
+
+static inline void *
+get_sym_cop(struct rte_crypto_op *cop)
+{
+	return (cop + 1);
+}
+
 int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx);
 
-- 
2.5.5

^ permalink raw reply related

* [PATCH v3 2/9] examples/ipsec-secgw: reset crypto operation status
From: Sergio Gonzalez Monroy @ 2016-09-29 15:44 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch
In-Reply-To: <1475163857-142366-1-git-send-email-sergio.gonzalez.monroy@intel.com>

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 examples/ipsec-secgw/ipsec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c
index 1e87d0d..f49143b 100644
--- a/examples/ipsec-secgw/ipsec.c
+++ b/examples/ipsec-secgw/ipsec.c
@@ -124,6 +124,7 @@ ipsec_enqueue(ipsec_xform_fn xform_func, struct ipsec_ctx *ipsec_ctx,
 		priv->sa = sa;
 
 		priv->cop.type = RTE_CRYPTO_OP_TYPE_SYMMETRIC;
+		priv->cop.status = RTE_CRYPTO_OP_STATUS_NOT_PROCESSED;
 
 		rte_prefetch0(&priv->sym_cop);
 		priv->cop.sym = &priv->sym_cop;
-- 
2.5.5

^ permalink raw reply related

* [PATCH v3 0/9] IPsec Enhancements
From: Sergio Gonzalez Monroy @ 2016-09-29 15:44 UTC (permalink / raw)
  To: dev; +Cc: pablo.de.lara.guarch
In-Reply-To: <1474616734-118291-1-git-send-email-sergio.gonzalez.monroy@intel.com>

This patch set mainly adds support for AES-GCM and AES-CTR.

It also updates the IV generation method for AES-CBC mode using
the forward function instead of randomly generating the IV.

v3:
 - update sample app guide
 - remove unused function
 - improve commit messages

v2:
 - Update releas notes.
 - Initialize salt values, GCM/CTR key length now is 20B,
   16B key and 4 LSB salt.
 - Do not check SP/ACL if we have no rules.
 - Add macro for cryptodev queue size

Dependencies:
examples/ipsec-secgw: add configuration file support
http://dpdk.org/dev/patchwork/patch/16004/

examples/ipsec-secgw: add sample configuration files
http://dpdk.org/dev/patchwork/patch/16003/

Sergio Gonzalez Monroy (9):
  examples/ipsec-secgw: change CBC IV generation
  examples/ipsec-secgw: reset crypto operation status
  examples/ipsec-secgw: add AES-GCM support
  examples/ipsec-secgw: enable AES-CTR mode
  examples/ipsec-secgw: check sp only when setup
  examples/ipsec-secgw: add cryptodev queue size macro
  examples/ipsec-secgw: initialize sa salt
  examples/ipsec-secgw: update release notes
  examples/ipsec-secgw: update ipsec-secgw guide

 doc/guides/rel_notes/release_16_11.rst   |   9 ++
 doc/guides/sample_app_ug/ipsec_secgw.rst |  15 ++--
 examples/ipsec-secgw/esp.c               | 144 ++++++++++++++++++++++---------
 examples/ipsec-secgw/ipsec-secgw.c       |   7 +-
 examples/ipsec-secgw/ipsec.c             |   1 +
 examples/ipsec-secgw/ipsec.h             |  35 +++++++-
 examples/ipsec-secgw/sa.c                |  54 ++++++++++--
 7 files changed, 207 insertions(+), 58 deletions(-)

-- 
2.5.5

^ permalink raw reply

* Re: [Qemu-devel] [PATCH 1/2] vhost: enable any layout feature
From: Maxime Coquelin @ 2016-09-29 15:30 UTC (permalink / raw)
  To: Yuanhan Liu, Michael S. Tsirkin; +Cc: Stephen Hemminger, dev, qemu-devel
In-Reply-To: <20160928022848.GE1597@yliu-dev.sh.intel.com>



On 09/28/2016 04:28 AM, Yuanhan Liu wrote:
> On Tue, Sep 27, 2016 at 10:56:40PM +0300, Michael S. Tsirkin wrote:
>> On Tue, Sep 27, 2016 at 11:11:58AM +0800, Yuanhan Liu wrote:
>>> On Mon, Sep 26, 2016 at 10:24:55PM +0300, Michael S. Tsirkin wrote:
>>>> On Mon, Sep 26, 2016 at 11:01:58AM -0700, Stephen Hemminger wrote:
>>>>> I assume that if using Version 1 that the bit will be ignored
>>>
>>> Yes, but I will just quote what you just said: what if the guest
>>> virtio device is a legacy device? I also gave my reasons in another
>>> email why I consistently set this flag:
>>>
>>>   - we have to return all features we support to the guest.
>>>
>>>     We don't know the guest is a modern or legacy device. That means
>>>     we should claim we support both: VERSION_1 and ANY_LAYOUT.
>>>
>>>     Assume guest is a legacy device and we just set VERSION_1 (the current
>>>     case), ANY_LAYOUT will never be negotiated.
>>>
>>>   - I'm following the way Linux kernel takes: it also set both features.
>>>
>>>   Maybe, we could unset ANY_LAYOUT when VERSION_1 is _negotiated_?
>>>
>>> The unset after negotiation I proposed turned out it won't work: the
>>> feature is already negotiated; unsetting it only in vhost side doesn't
>>> change anything. Besides, it may break the migration as Michael stated
>>> below.
>>
>> I think the reverse. Teach vhost user that for future machine types
>> only VERSION_1 implies ANY_LAYOUT.
>>
>>
>>>> Therein lies a problem. If dpdk tweaks flags, updating it
>>>> will break guest migration.
>>>>
>>>> One way is to require that users specify all flags fully when
>>>> creating the virtio net device.
>>>
>>> Like how? By a new command line option? And user has to type
>>> all those features?
>>
>> Make libvirt do this.  users use management normally. those that don't
>> likely don't migrate VMs.
>
> Fair enough.
>
>>
>>>> QEMU could verify that all required
>>>> flags are set, and fail init if not.
>>>>
>>>> This has other advantages, e.g. it adds ability to
>>>> init device without waiting for dpdk to connect.
>
> Will the feature negotiation between DPDK and QEMU still exist
> in your proposal?
>
>>>>
>>>> However, enabling each new feature would now require
>>>> management work. How about dpdk ships the list
>>>> of supported features instead?
>>>> Management tools could read them on source and destination
>>>> and select features supported on both sides.
>>>
>>> That means the management tool would somehow has a dependency on
>>> DPDK project, which I have no objection at all. But, is that
>>> a good idea?
>>
>> It already starts the bridge somehow, does it not?
>
> Indeed. I was firstly thinking about reading the dpdk source file
> to determine the DPDK supported feature list, with which the bind
> is too tight. I later realized you may ask DPDK to provide a binary
> to dump the list, or something like that.
>
>>
>>> BTW, I'm not quite sure I followed your idea. I mean, how it supposed
>>> to fix the ANY_LAYOUT issue here? How this flag will be set for
>>> legacy device?
>>>
>>> 	--yliu
>>
>> For ANY_LAYOUT, I think we should just set in in qemu,
>> but only for new machine types.
>
> What do you mean by "new machine types"? Virtio device with newer
> virtio-spec version?
>
>> This addresses migration
>> concerns.
>
> To make sure I followed you, do you mean the migration issue from
> an older "dpdk + qemu" combo to a newer "dpdk + qemu" combo (that
> more new features might be shipped)?
>
> Besides that, your proposal looks like a big work to accomplish.
> Are you okay to make it simple first: set it consistently like
> what Linux kernel does? This would at least make the ANY_LAYOUT
> actually be enabled for legacy device (which is also the default
> one that's widely used so far).

Before enabling anything by default, we should first optimize the 1 slot
case. Indeed, micro-benchmark using testpmd in txonly[0] shows ~17%
perf regression for 64 bytes case:
  - 2 descs per packet: 11.6Mpps
  - 1 desc per packet: 9.6Mpps

This is due to the virtio header clearing in virtqueue_enqueue_xmit().
Removing it, we get better results than with 2 descs (1.20Mpps).
Since the Virtio PMD doesn't support offloads, I wonder whether we can
just drop the memset?

  -- Maxime
[0]: For testing, you'll need these patches, else only first packets
will use a single slot:
  - http://dpdk.org/dev/patchwork/patch/16222/
  - http://dpdk.org/dev/patchwork/patch/16223/

^ permalink raw reply

* Re: [PATCH v5 1/3] librte_ether: add API for VF management
From: Iremonger, Bernard @ 2016-09-29 15:16 UTC (permalink / raw)
  To: Thomas Monjalon
  Cc: dev@dpdk.org, Shah, Rahul R, Lu, Wenzhuo, az5157@att.com,
	azelezniak
In-Reply-To: <3631809.sFy4WKcCTS@xps13>

Hi Thomas,

<snip>

> Subject: Re: [dpdk-dev] [PATCH v5 1/3] librte_ether: add API for VF
> management
> 
> 2016-09-29 15:16, Bernard Iremonger:
> > Add new API function to configure and manage VF's on a NIC.
> >
> > add rte_eth_dev_set_vf_vlan_stripq function.
> >
> > Signed-off-by: azelezniak <alexz@att.com>
> 
> We need the full name of azelezniak.

It is Alex Zelezniak, I will update the commit messages.

> > Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
> [...]
> > +int
> > +rte_eth_dev_set_vf_vlan_stripq(uint8_t port, uint16_t vf, int on);
> 
> Why keeping this function in ethdev?

This function is using an existing API in the eth_dev_ops structure.

dev->dev_ops->vlan_strip_queue_set

The vlan_strip_queue_set API is used by  the i40e, ixgbe and mlx5 PMD's.

> I think it would be more consistent to have also existing VF functions moving
> from ethdev to rte_pmd_ixgbe.h.
> You cannot remove them, but you can create their ixgbe-specific version and
> announce that the ethdev ones are deprecated.

There are 5 existing VF functions which are only used by ixgbe PMD at present.
It would make sense to create ixgbe-specific versions, however I think this should be done in a separate patchset.

Regards,

Bernard

 

^ permalink raw reply

* Re: [PATCH v3 5/6] ixgbe: add Tx preparation
From: Kulasek, TomaszX @ 2016-09-29 15:12 UTC (permalink / raw)
  To: Ananyev, Konstantin, dev@dpdk.org
In-Reply-To: <2601191342CEEE43887BDE71AB9772583F0BC604@irsmsx105.ger.corp.intel.com>

Hi Konstantin,

> -----Original Message-----
> From: Ananyev, Konstantin
> Sent: Thursday, September 29, 2016 13:09
> To: Kulasek, TomaszX <tomaszx.kulasek@intel.com>; dev@dpdk.org
> Subject: RE: [PATCH v3 5/6] ixgbe: add Tx preparation
> 
> Hi Tomasz,
> 
> > Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
> > ---

...

> > +*/
> > +uint16_t
> > +ixgbe_prep_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t
> > +nb_pkts) {
> > +	int i, ret;
> > +	struct rte_mbuf *m;
> > +	struct ixgbe_tx_queue *txq = (struct ixgbe_tx_queue *)tx_queue;
> > +
> > +	for (i = 0; i < nb_pkts; i++) {
> > +		m = tx_pkts[i];
> > +
> > +		/**
> > +		 * Check if packet meets requirements for number of
> segments
> > +		 *
> > +		 * NOTE: for ixgbe it's always (40 - WTHRESH) for both TSO
> and non-TSO
> > +		 */
> > +
> > +		if (m->nb_segs > IXGBE_TX_MAX_SEG - txq->wthresh) {
> > +			rte_errno = -EINVAL;
> > +			return i;
> > +		}
> > +
> > +		if (m->ol_flags & IXGBE_TX_OFFLOAD_NOTSUP_MASK) {
> > +			rte_errno = -EINVAL;
> > +			return i;
> > +		}
> > +
> > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG
> > +		ret = rte_validate_tx_offload(m);
> > +		if (ret != 0) {
> > +			rte_errno = ret;
> > +			return i;
> > +		}
> > +#endif
> > +		ret = rte_phdr_cksum_fix(m);
> > +		if (ret != 0) {
> > +			rte_errno = ret;
> > +			return i;
> > +		}
> > +	}
> > +
> > +	return i;
> > +}
> > +
> > +/* ixgbe simple path as well as vector TX doesn't support tx offloads
> > +*/ uint16_t ixgbe_prep_pkts_simple(void *tx_queue __rte_unused,
> > +struct rte_mbuf **tx_pkts,
> > +		uint16_t nb_pkts)
> > +{
> > +	int i;
> > +	struct rte_mbuf *m;
> > +	uint64_t ol_flags;
> > +
> > +	for (i = 0; i < nb_pkts; i++) {
> > +		m = tx_pkts[i];
> > +		ol_flags = m->ol_flags;
> > +
> > +		/* simple tx path doesn't support multi-segments */
> > +		if (m->nb_segs != 1) {
> > +			rte_errno = -EINVAL;
> > +			return i;
> > +		}
> > +
> > +		/* For simple path (simple and vector) no tx offloads are
> supported */
> > +		if (ol_flags & PKT_TX_OFFLOAD_MASK) {
> > +			rte_errno = -EINVAL;
> > +			return i;
> > +		}
> > +	}
> > +
> > +	return i;
> > +}
> 
> Just thought about it once again:
> As now inside rte_eth_tx_prep() we do now:
> +
> +	if (!dev->tx_pkt_prep)
> +		return nb_pkts;
> 
> Then there might be a better approach to set
> dev->tx_pkt_prep = NULL
> for simple and vector TX functions?
> 
> After all, prep_simple() does nothing but returns an error if conditions are
> not met.
> And if simple TX was already selected, then that means that user deliberately
> disabled all HW TX offloads in favor of faster TX and there is no point to slow
> him down with extra checks here.
> Same for i40e and fm10k.
> What is your opinion?
> 
> Konstantin
> 

Yes, if performance is a key, and, while the limitations of vector/simple path are quite well documented, these additional checks are a bit overzealous. We may assume that to made tx offloads working, we need to configure driver in a right way, and this is a configuration issue if something doesn't work.

I will remove it.

Tomasz

^ permalink raw reply

* Re: [PATCH v2 1/7] examples/ipsec-secgw: change CBC IV generation
From: Sergio Gonzalez Monroy @ 2016-09-29 14:39 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev@dpdk.org
In-Reply-To: <E115CCD9D858EF4F90C690B0DCB4D8973CA00486@IRSMSX108.ger.corp.intel.com>

On 28/09/2016 04:51, De Lara Guarch, Pablo wrote:
> Hi Sergio,
>
>> -----Original Message-----
>> From: Gonzalez Monroy, Sergio
>> Sent: Friday, September 23, 2016 12:45 AM
>> To: dev@dpdk.org; De Lara Guarch, Pablo
>> Subject: [PATCH v2 1/7] examples/ipsec-secgw: change CBC IV generation
>>
>> NIST SP800-38A recommends two methods to generate unpredictable IVs
>> (Initilisation Vector) for CBC mode:
>> 1) Apply the forward function to a nonce (ie. counter)
>> 2) Use a FIPS-approved random number generator
>>
>> This patch implements the first recommended method by using the forward
>> function to generate the IV.
>>
>> Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
> [...]
>
>> +static inline void *
>> +get_cop(struct rte_mbuf *m)
>> +{
>> +	struct ipsec_mbuf_metadata *priv = get_priv(m);
>> +
>> +	return &priv->cop;
>> +}
> This function is not used in anywhere. Should it be called somewhere to get the crypto op?

Indeed!
Will be removed in v3.

>> +
>> +static inline void *
>> +get_sym_cop(struct rte_crypto_op *cop)
>> +{
>> +	return (cop + 1);
> Why is this cop + 1? Am I missing something obvious?
> Maybe it is worth a comment here (I noticed this was already in the previous code, but I don't understand it :))

It is just the way the app stores the metadata.
If you look at 'struct ipsec_mbuf_metadata' you can see that sym_cop is 
just after cop.

Sergio

>> +}
>> +
>>   int
>>   inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t
>> sa_idx);
>>
>> --
>> 2.5.5
> Thanks,
> Pablo

^ permalink raw reply

* Re: [PATCH 13/13] net/thunderx: document secondary queue set support
From: Maciej Czekaj @ 2016-09-29 14:38 UTC (permalink / raw)
  To: Mcnamara, John, Kamil Rytarowski, dev@dpdk.org
  Cc: zyta.szpak@semihalf.com, slawomir.rosek@semihalf.com,
	rad@semihalf.com, jerin.jacob@caviumnetworks.com,
	Kamil Rytarowski
In-Reply-To: <B27915DBBA3421428155699D51E4CFE202623183@IRSMSX103.ger.corp.intel.com>


We will address all the issues in v2.


>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Kamil Rytarowski
>> Sent: Friday, August 26, 2016 5:54 PM
>> To: dev@dpdk.org
>> Cc: maciej.czekaj@caviumnetworks.com; zyta.szpak@semihalf.com;
>> slawomir.rosek@semihalf.com; rad@semihalf.com;
>> jerin.jacob@caviumnetworks.com; Kamil Rytarowski
>> <kamil.rytarowski@caviumnetworks.com>
>> Subject: [dpdk-dev] [PATCH 13/13] net/thunderx: document secondary queue
>> set support
>>
>
> There are some whitespace errors in the docs:
>
>     Applying patch #15435 using 'git am'
>     Description: [dpdk-dev,13/13] net/thunderx: document secondary queue set support
>     Applying: net/thunderx: document secondary queue set support
>     .git/rebase-apply/patch:70: trailing whitespace.
>
>     .git/rebase-apply/patch:74: trailing whitespace.
>
>     .git/rebase-apply/patch:98: trailing whitespace.
>
>
>
> Some other minor comments below.
>
>
>
>>
>>  Supported ThunderX SoCs
>>  -----------------------
>> @@ -322,6 +323,112 @@ This section provides instructions to configure SR-
>> IOV with Linux OS.
>>  #. Refer to section :ref:`Running testpmd <thunderx_testpmd_example>` for
>> instruction
>>     how to launch ``testpmd`` application.
>>
>> +Multiple Queue Set per DPDK port configuration
>> +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> +
>> +There are two types of VFs:
>> +
>> +- Primary VF
>> +- Secondary VF
>> +
>> +Each port consist of a primary VF and n secondary VF(s). Each VF provides
>
> s/consist/consists/
>
>
>> 8 Tx/Rx queues to a port.
>> +In case port is configured to use more than 8 queues, then it requires
>> +one (or more) secondary VF. Each secondary VF adds additional 8 queues to
>> the queue set.
>
> There are a few missing definite and indefinite articles missing in the text.
>
>
>> +
>> +During PMD driver initialization, the primary VF's are enumerated by
>> +checking the specific flag (see sqs message in DPDK boot log - sqs
>> indicates secondary queue set).
>> +They are at the beginning of VF list (the remain ones are secondary
>> VF's).
>> +
>> +The primary VFs are used as master queue sets. Secondary VFs provid
>
> s/provid/provide/
>
>> +additional queue sets for primary ones. If a port is configured for
>> +more then
>> +8 queues than it will request for additional queues from secondary VFs.
>> +
>> +Secondary VFs cannot be shared between primary VFs.
>> +
>> +Primary VFs are present on the beginning of the 'Network devices using
>> +kernel driver' list, secondary VFs are on the remaining on the remaining
>> part of the list.
>> +
>> +   .. note::
>> +
>
> This note and the following one are indented too far. They should be aligned with the margin.
>
>
>
>> ...
>
>
>> +Example device binding
>> +~~~~~~~~~~~~~~~~~~~~~~
>> +
>> +If a system has three interfaces, a total of 18 VF devices will be
>> +created on a non-NUMA machine.
>> +
>> +   .. note::
>> +
>> +      NUMA systems have 12 VFs per port and non-NUMA 6 VFs per port.
>> +
>> +   .. code-block:: console
>
> This note and code block are indented too far. They should be aligned with the margin.
>
>
>> +
>> +      # tools/dpdk-devbind.py --status
>> +
>> +      Network devices using DPDK-compatible driver
>> +      ============================================
>> +      <none>
>> +
>> +      Network devices using kernel driver
>> +      ===================================
>> +      0000:01:10.0 'Device a026' if= drv=thunder-BGX unused=vfio-
>> pci,uio_pci_generic
>> +      0000:01:10.1 'Device a026' if= drv=thunder-BGX unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.0 'Device a01e' if= drv=thunder-nic unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.1 'Device 0011' if=eth0 drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.2 'Device 0011' if=eth1 drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.3 'Device 0011' if=eth2 drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.4 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.5 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.6 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:00.7 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.0 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.1 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.2 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.3 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.4 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.5 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.6 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:01.7 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:02.0 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:02.1 'Device 0011' if= drv=thunder-nicvf unused=vfio-
>> pci,uio_pci_generic
>> +      0002:01:02.2 'Device 0011' if= drv=thunder-nicvf
>> + unused=vfio-pci,uio_pci_generic
>> +
>> +      Other network devices
>> +      =====================
>> +      0002:00:03.0 'Device a01f' unused=vfio-pci,uio_pci_generic
>> +
>> +
>> +We want to bind two physical interfaces with 24 queues each device, we
>> +attach two primary VFs and four secondary queues. In our example we
>> choose two 10G interfaces eth1 (0002:01:00.2) and eth2 (0002:01:00.3).
>> +We will chose four secondary queue sets from the ending of the list
>> (0002:01:01.7-0002:01:02.2).
>
> s/chose/choose/
>
>> +
>> +
>> +#. Bind two primary VFs to the ``vfio-pci`` driver:
>> +
>> +   .. code-block:: console
>> +
>
> These code blocks are indented correctly.
>
>
> John.
>

^ permalink raw reply

* Re: [PATCH 12/13] net/thunderx: add final bits for secondary queue support
From: Maciej Czekaj @ 2016-09-29 14:37 UTC (permalink / raw)
  To: Ferruh Yigit, Kamil Rytarowski, dev
  Cc: zyta.szpak, slawomir.rosek, rad, jerin.jacob, Kamil Rytarowski
In-Reply-To: <c5735d68-1268-744e-f45d-ea76f82da0b5@intel.com>

> On 8/26/2016 5:54 PM, Kamil Rytarowski wrote:
>> From: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>>
>> Signed-off-by: Maciej Czekaj <maciej.czekaj@caviumnetworks.com>
>> Signed-off-by: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>> Signed-off-by: Zyta Szpak <zyta.szpak@semihalf.com>
>> Signed-off-by: Slawomir Rosek <slawomir.rosek@semihalf.com>
>> Signed-off-by: Radoslaw Biernacki <rad@semihalf.com>
>> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>> ---
>
> Is it possible to give more details what has been done in this patch for
> secondary queue support?
>
> thanks,
> ferruh
>
>
>

Will add more details in v2.

^ permalink raw reply

* Re: [PATCH 07/13] net/thunderx: fix multiprocess support in stats
From: Maciej Czekaj @ 2016-09-29 14:35 UTC (permalink / raw)
  To: Ferruh Yigit, Kamil Rytarowski, dev
  Cc: zyta.szpak, slawomir.rosek, rad, jerin.jacob, Kamil Rytarowski
In-Reply-To: <30b54539-0ccf-65b3-c158-3f55a40a274b@intel.com>

> On 8/26/2016 5:54 PM, Kamil Rytarowski wrote:
>> From: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>>
>> In case of the multiprocess mode a shared nicvf struct between processes
>> cannot point with the eth_dev pointer to master device, therefore remove it
>> allong with references to it refactoring the code where needed.
>
> Patch subject says fix multiprocess support in stat, but it seems doing
> more than just for stats fix.
>
> Overall eliminates private_data->eht_dev link.
>
> I guess this is because eth_dev->data is shared for primary and
> secondary processes, and this makes impossible to use separate
> private_data for primary and secondaries.
>
> So this patch looks like keeping separate copy of private_data (nic) and
> using eth_dev and nic structs for functions instead of using
> eth_dev->data->private_data.
>
> If above correct, can you please updated patch subject?
>
> Also another approach can be allocating "data" independently and
> overwrite eth_dev->data with this per each process, this also makes
> eth_dev->data->private_data usable for each process.
>
>>
>> Fixes: 7413feee662d ("net/thunderx: add device start/stop and close")
>>
>> Signed-off-by: Maciej Czekaj <maciej.czekaj@caviumnetworks.com>
>> Signed-off-by: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>> Signed-off-by: Zyta Szpak <zyta.szpak@semihalf.com>
>> Signed-off-by: Slawomir Rosek <slawomir.rosek@semihalf.com>
>> Signed-off-by: Radoslaw Biernacki <rad@semihalf.com>
>> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>> ---
>
>
>

Yes, this patch enables multi-process support for primary and secondary 
functions by eliminating the pointer from private struct to eth_dev.

Will extend the comment in v2.

^ permalink raw reply

* Re: [PATCH v2 8/8] examples/ipsec-secgw: update release notes
From: Sergio Gonzalez Monroy @ 2016-09-29 14:32 UTC (permalink / raw)
  To: De Lara Guarch, Pablo, dev@dpdk.org
In-Reply-To: <E115CCD9D858EF4F90C690B0DCB4D8973CA004BD@IRSMSX108.ger.corp.intel.com>

On 28/09/2016 05:05, De Lara Guarch, Pablo wrote:
> Hi Sergio,
>
>> -----Original Message-----
>> From: Gonzalez Monroy, Sergio
>> Sent: Friday, September 23, 2016 12:46 AM
>> To: dev@dpdk.org; De Lara Guarch, Pablo
>> Subject: [PATCH v2 8/8] examples/ipsec-secgw: update release notes
>>
>> Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
>> ---
>>   doc/guides/rel_notes/release_16_11.rst | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/doc/guides/rel_notes/release_16_11.rst
>> b/doc/guides/rel_notes/release_16_11.rst
>> index 373053a..12f507b 100644
>> --- a/doc/guides/rel_notes/release_16_11.rst
>> +++ b/doc/guides/rel_notes/release_16_11.rst
>> @@ -89,6 +89,15 @@ Examples
>>     ipsec-secgw sample application now supports configuration file to specify
>>     SP, SA, and routing rules.
>>
>> +* **ipsec-secgw: AES GCM/CTR mode support**
>> +
>> +  Support AES Counter (CTR) and Galois-Counter Mode (GCM) in IPSec ESP.
>> +
>> +* **ipsec-secgw: AES CBC IV generation**
>> +
>> +  Use cipher forward function on unique counter blocks (same approach as
>> +  CTR/GCM) to generate the IV instead of a random value.
>> +
>>   Other
>>   ~~~~~
>>
>> --
>> 2.5.5
> This should go under "New features" section, not under "Resolved issues".
> I have seen that other people have made the same mistake,
> which tells me that we might need to change this
> (there are different subsections only under Resolved Issues).

Will fix on v3.

Sergio

> Thanks,
> Pablo

^ permalink raw reply

* Re: [PATCH v5 1/3] librte_ether: add API for VF management
From: Thomas Monjalon @ 2016-09-29 14:30 UTC (permalink / raw)
  To: Bernard Iremonger; +Cc: dev, rahul.r.shah, wenzhuo.lu, az5157, azelezniak
In-Reply-To: <1475158591-2243-2-git-send-email-bernard.iremonger@intel.com>

2016-09-29 15:16, Bernard Iremonger:
> Add new API function to configure and manage VF's on a NIC.
> 
> add rte_eth_dev_set_vf_vlan_stripq function.
> 
> Signed-off-by: azelezniak <alexz@att.com>

We need the full name of azelezniak.

> Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
[...]
> +int
> +rte_eth_dev_set_vf_vlan_stripq(uint8_t port, uint16_t vf, int on);

Why keeping this function in ethdev?

I think it would be more consistent to have also existing VF functions
moving from ethdev to rte_pmd_ixgbe.h.
You cannot remove them, but you can create their ixgbe-specific version
and announce that the ethdev ones are deprecated.

^ permalink raw reply

* Re: [PATCH] app/test: Remove hard coding for nb_queue_pairs in test_cryptodev
From: De Lara Guarch, Pablo @ 2016-09-29 14:29 UTC (permalink / raw)
  To: Thomas Monjalon, Trahe, Fiona; +Cc: dev@dpdk.org, akhil.goyal@nxp.com
In-Reply-To: <2002488.2H5o8Bgc8G@xps13>



> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas.monjalon@6wind.com]
> Sent: Thursday, September 29, 2016 7:25 AM
> To: Trahe, Fiona
> Cc: dev@dpdk.org; De Lara Guarch, Pablo; akhil.goyal@nxp.com
> Subject: Re: [dpdk-dev] [PATCH] app/test: Remove hard coding for
> nb_queue_pairs in test_cryptodev
> 
> 2016-09-29 14:12, Trahe, Fiona:
> > > > From: Akhil Goyal <akhil.goyal@nxp.com>
> > > >
> > > > nb_queue_pairs should not be hard coded with device specific number.
> > > > It should be retrieved from the device infos.
> > > > Also in ut_setup, ts_params->conf.nb_queue_pairs is already set in
> > > > testsuite_setup and we are not modifying it.
> > > >
> > > > Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> > >
> > > Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> >
> > The above code is correct, however it exposes a bug in QAT PMD unit tests.
> > And some cleanup needed for unnecessary qp setup code.
> > That cleanup then exposed a bug in aesni_mb PMD which prevents re-
> creating queue pairs of a different size.
> >
> > I have a fix and cleanup patch ready.
> > Just not sure how best to push it?
> > The original patch also needs rebasing, doesn't apply cleanly to the latest
> dpdk-next-crypto
> >
> > Pablo should I push all as a reply to the first patch - waiting first for that to
> be rebased?
> > Or
> > It would save Akhil a rebase and be simpler if I can include the original
> change in my patch and push all as a v2 superceding the original patch?  Is
> this possible?
> > Or
> > should I Nack the original patch and push all instead?
> 
> My preference goes to a v2.

Agree, send a v2, including your name and Akhil's. 

Thanks,
Pablo

^ permalink raw reply

* Re: [PATCH v2]:rte_timer:timer lag issue correction
From: Karmarkar Suyash @ 2016-09-29 14:27 UTC (permalink / raw)
  To: dev@dpdk.org, thomas.monjalon@6wind.com, rsanford@akamai.com,
	reshma.pattan@intel.com
In-Reply-To: <20160921205427.14116-1-skarmarkar@sonusnet.com>

Hello,

Can you please review the changes and suggest next steps? Thanks

Regards
Suyash Karmarkar

-----Original Message-----
From: Karmarkar Suyash 
Sent: Wednesday, September 21, 2016 4:54 PM
To: dev@dpdk.org; thomas.monjalon@6wind.com; rsanford@akamai.com; reshma.pattan@intel.com
Cc: Karmarkar Suyash <skarmarkar@sonusnet.com>
Subject: [PATCH v2]:rte_timer:timer lag issue correction

For Periodic timers ,if the lag gets introduced, the current code 
added additional delay when the next peridoc timer was initialized 
by not taking into account the delay added, with this fix the code 
would start the next occurrence of timer keeping in account the 
lag added.Corrected the behavior.

Fixes: 9b15ba89 ("timer: use a skip list")

Karmarkar Suyash (1):
Signed-off-by: Karmarkar Suyash <skarmarkar@sonusnet.com>

 lib/librte_timer/rte_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

 
---
 lib/librte_timer/rte_timer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_timer/rte_timer.c b/lib/librte_timer/rte_timer.c
index 43da836..18782fa 100644
--- a/lib/librte_timer/rte_timer.c
+++ b/lib/librte_timer/rte_timer.c
@@ -613,7 +613,7 @@ void rte_timer_manage(void)
 			status.owner = (int16_t)lcore_id;
 			rte_wmb();
 			tim->status.u32 = status.u32;
-			__rte_timer_reset(tim, cur_time + tim->period,
+			__rte_timer_reset(tim, tim->expire + tim->period,
 				tim->period, lcore_id, tim->f, tim->arg, 1);
 			rte_spinlock_unlock(&priv_timer[lcore_id].list_lock);
 		}

-- 
2.9.3.windows.1

^ permalink raw reply related

* Re: [PATCH] app/test: Remove hard coding for nb_queue_pairs in test_cryptodev
From: Thomas Monjalon @ 2016-09-29 14:25 UTC (permalink / raw)
  To: Trahe, Fiona; +Cc: dev, De Lara Guarch, Pablo, akhil.goyal@nxp.com
In-Reply-To: <348A99DA5F5B7549AA880327E580B435890E9364@IRSMSX101.ger.corp.intel.com>

2016-09-29 14:12, Trahe, Fiona:
> > > From: Akhil Goyal <akhil.goyal@nxp.com>
> > >
> > > nb_queue_pairs should not be hard coded with device specific number.
> > > It should be retrieved from the device infos.
> > > Also in ut_setup, ts_params->conf.nb_queue_pairs is already set in
> > > testsuite_setup and we are not modifying it.
> > >
> > > Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
> > 
> > Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> 
> The above code is correct, however it exposes a bug in QAT PMD unit tests.
> And some cleanup needed for unnecessary qp setup code.
> That cleanup then exposed a bug in aesni_mb PMD which prevents re-creating queue pairs of a different size.
>  
> I have a fix and cleanup patch ready. 
> Just not sure how best to push it?
> The original patch also needs rebasing, doesn't apply cleanly to the latest dpdk-next-crypto
> 
> Pablo should I push all as a reply to the first patch - waiting first for that to be rebased?
> Or 
> It would save Akhil a rebase and be simpler if I can include the original change in my patch and push all as a v2 superceding the original patch?  Is this possible?
> Or 
> should I Nack the original patch and push all instead?

My preference goes to a v2.

^ permalink raw reply

* Re: [PATCH 04/13] net/thunderx/base: add secondary queue set support
From: Maciej Czekaj @ 2016-09-29 14:22 UTC (permalink / raw)
  To: Ferruh Yigit, Kamil Rytarowski, dev
  Cc: zyta.szpak, slawomir.rosek, rad, jerin.jacob, Kamil Rytarowski
In-Reply-To: <531538a8-5a7b-b5ee-10b9-46e7bbb1acd0@intel.com>

> On 8/26/2016 5:53 PM, Kamil Rytarowski wrote:
>> From: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>>
>> Changes:
>>  - add new message sqs_alloc in mailbox
>>  - add a queue container to hold secondary qsets.
>>  - add nicvf_mbox_request_sqs
>>  - handle new mailbox messages for secondary queue set support
>>  - register secondary queue sets for furthe reuse
>>  - register the number secondary queue sets in MSG_QS_CFG
>>
>> Signed-off-by: Maciej Czekaj <maciej.czekaj@caviumnetworks.com>
>> Signed-off-by: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>> Signed-off-by: Zyta Szpak <zyta.szpak@semihalf.com>
>> Signed-off-by: Slawomir Rosek <slawomir.rosek@semihalf.com>
>> Signed-off-by: Radoslaw Biernacki <rad@semihalf.com>
>> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>> ---
>>  drivers/net/thunderx/base/nicvf_hw_defs.h |  1 +
>>  drivers/net/thunderx/base/nicvf_mbox.c    | 34 ++++++++++++++++++++++++++++++-
>>  drivers/net/thunderx/base/nicvf_mbox.h    | 21 +++++++++++++++++--
>>  drivers/net/thunderx/nicvf_struct.h       |  5 +++++
>>  4 files changed, 58 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/thunderx/base/nicvf_hw_defs.h b/drivers/net/thunderx/base/nicvf_hw_defs.h
>> index 2f2b225..3b947e0 100644
>> --- a/drivers/net/thunderx/base/nicvf_hw_defs.h
>> +++ b/drivers/net/thunderx/base/nicvf_hw_defs.h
>> @@ -207,6 +207,7 @@
>>  #define NICVF_CQE_RX2_RBPTR_WORD        (7)
>>
>>  #define NICVF_STATIC_ASSERT(s) _Static_assert(s, #s)
>> +#define assert_if_secondary(nic) assert((nic)->sqs_mode == 0)
>
> assert_if_not_secondary?
>
>

Will be refactored to macro nic_is_primary in v2.

^ permalink raw reply

* Re: [PATCH] eal: fix bug in x86 cmpset
From: Thomas Monjalon @ 2016-09-29 14:21 UTC (permalink / raw)
  To: Rao, Nikhil; +Cc: dev, Christian Ehrhardt, stable
In-Reply-To: <57ED141F.8020302@intel.com>

2016-09-29 18:46, Rao, Nikhil:
> 
> On 9/29/2016 6:35 PM, Christian Ehrhardt wrote:
> > The patch misses a fixed: line which it should get I think.
> 
> The bug has existed from the day the DPDK was open-sourced, i.e, there wasn't a specific
> commit that introduced this feature/bug, hence wasn't sure if it needed the fixes tag.

In this case, we use the first commit:
	af75078 first public release
It means it can be backported everywhere.

^ permalink raw reply

* Re: [PATCH 01/13] net/thunderx: cleanup the driver before adding new features
From: Maciej Czekaj @ 2016-09-29 14:21 UTC (permalink / raw)
  To: Ferruh Yigit, Kamil Rytarowski, dev
  Cc: zyta.szpak, slawomir.rosek, rad, jerin.jacob, Kamil Rytarowski
In-Reply-To: <568fafa1-53f3-980b-9ca4-e086980651b2@intel.com>

> On 8/26/2016 5:53 PM, Kamil Rytarowski wrote:
>> From: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>>
>> Refactored features:
>>  - enable nicvf_qset_rbdr_precharge to handle handle secondary queue sets
> double "handle"

Will fix comment in v2.

>
>>  - rte_free already handles NULL pointer	
>>  - check mempool flags to predict being contiguous in memory
>>  - allow to use mempool with multiple memory chunks
>
> I am not able to find the implementation for this.

As commented below, it is not true so will remove that point in v2.


>
>>  - simplify local construct of accessing nb_rx_queus
> s/nb_rx_queus/nb_rx_queues


Will fix comment in v2.


>
>>
>> Signed-off-by: Maciej Czekaj <maciej.czekaj@caviumnetworks.com>
>> Signed-off-by: Kamil Rytarowski <kamil.rytarowski@caviumnetworks.com>
>> Signed-off-by: Zyta Szpak <zyta.szpak@semihalf.com>
>> Signed-off-by: Slawomir Rosek <slawomir.rosek@semihalf.com>
>> Signed-off-by: Radoslaw Biernacki <rad@semihalf.com>
>> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>> ---
>>  drivers/net/thunderx/base/nicvf_hw.c | 10 +++++-----
>>  drivers/net/thunderx/base/nicvf_hw.h |  6 +++---
>>  drivers/net/thunderx/nicvf_ethdev.c  | 32 ++++++++++++--------------------
>>  3 files changed, 20 insertions(+), 28 deletions(-)
>>
>> diff --git a/drivers/net/thunderx/base/nicvf_hw.c b/drivers/net/thunderx/base/nicvf_hw.c
>> index 4bdd183..1f08ef2 100644
>> --- a/drivers/net/thunderx/base/nicvf_hw.c
>> +++ b/drivers/net/thunderx/base/nicvf_hw.c
>> @@ -141,7 +141,7 @@ nicvf_base_init(struct nicvf *nic)
>>  		return NICVF_ERR_BASE_INIT;
>>
>>  	if (nicvf_hw_version(nic) == PCI_SUB_DEVICE_ID_CN88XX_PASS2_NICVF)
>> -		nic->hwcap |= NICVF_CAP_TUNNEL_PARSING;
>> +		nic->hwcap |= NICVF_CAP_TUNNEL_PARSING | NICVF_CAP_CQE_RX2;
>
> is this new flag NICVF_CAP_CQE_RX2 flag described in commit log?
>
>>
>>  	if (nicvf_hw_version(nic) == PCI_SUB_DEVICE_ID_CN81XX_NICVF)
>>  		nic->hwcap |= NICVF_CAP_TUNNEL_PARSING | NICVF_CAP_CQE_RX2;
>> @@ -497,9 +497,9 @@ nicvf_qsize_rbdr_roundup(uint32_t val)
>>  }
>>
>>  int
>> -nicvf_qset_rbdr_precharge(struct nicvf *nic, uint16_t ridx,
>> -			  rbdr_pool_get_handler handler,
>> -			  void *opaque, uint32_t max_buffs)
>> +nicvf_qset_rbdr_precharge(void *dev, struct nicvf *nic,
>> +			  uint16_t ridx, rbdr_pool_get_handler handler,
>> +			  uint32_t max_buffs)
>>  {
>>  	struct rbdr_entry_t *desc, *desc0;
>>  	struct nicvf_rbdr *rbdr = nic->rbdr;
>> @@ -514,7 +514,7 @@ nicvf_qset_rbdr_precharge(struct nicvf *nic, uint16_t ridx,
>>  		if (count >= max_buffs)
>>  			break;
>>  		desc0 = desc + count;
>> -		phy = handler(opaque);
>> +		phy = handler(dev, nic);
>>  		if (phy) {
>>  			desc0->full_addr = phy;
>>  			count++;
>> diff --git a/drivers/net/thunderx/base/nicvf_hw.h b/drivers/net/thunderx/base/nicvf_hw.h
>> index a6cda82..2b8738b 100644
>> --- a/drivers/net/thunderx/base/nicvf_hw.h
>> +++ b/drivers/net/thunderx/base/nicvf_hw.h
>> @@ -85,7 +85,7 @@ enum nicvf_err_e {
>>  	NICVF_ERR_RSS_GET_SZ,    /* -8171 */
>>  };
>>
>> -typedef nicvf_phys_addr_t (*rbdr_pool_get_handler)(void *opaque);
>> +typedef nicvf_phys_addr_t (*rbdr_pool_get_handler)(void *dev, void *opaque);
>>
>>  struct nicvf_hw_rx_qstats {
>>  	uint64_t q_rx_bytes;
>> @@ -194,8 +194,8 @@ int nicvf_qset_reclaim(struct nicvf *nic);
>>
>>  int nicvf_qset_rbdr_config(struct nicvf *nic, uint16_t qidx);
>>  int nicvf_qset_rbdr_reclaim(struct nicvf *nic, uint16_t qidx);
>> -int nicvf_qset_rbdr_precharge(struct nicvf *nic, uint16_t ridx,
>> -			      rbdr_pool_get_handler handler, void *opaque,
>> +int nicvf_qset_rbdr_precharge(void *dev, struct nicvf *nic,
>> +			      uint16_t ridx, rbdr_pool_get_handler handler,
>>  			      uint32_t max_buffs);
>>  int nicvf_qset_rbdr_active(struct nicvf *nic, uint16_t qidx);
>>
>> diff --git a/drivers/net/thunderx/nicvf_ethdev.c b/drivers/net/thunderx/nicvf_ethdev.c
>> index 4402f6a..48f2cd2 100644
>> --- a/drivers/net/thunderx/nicvf_ethdev.c
>> +++ b/drivers/net/thunderx/nicvf_ethdev.c
>> @@ -691,7 +691,7 @@ nicvf_configure_cpi(struct rte_eth_dev *dev)
>>  	int ret;
>>
>>  	/* Count started rx queues */
>> -	for (qidx = qcnt = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++)
>> +	for (qidx = qcnt = 0; qidx < dev->data->nb_rx_queues; qidx++)
>>  		if (dev->data->rx_queue_state[qidx] ==
>>  		    RTE_ETH_QUEUE_STATE_STARTED)
>>  			qcnt++;
>> @@ -1023,12 +1023,9 @@ nicvf_stop_rx_queue(struct rte_eth_dev *dev, uint16_t qidx)
>>  static void
>>  nicvf_dev_rx_queue_release(void *rx_queue)
>>  {
>> -	struct nicvf_rxq *rxq = rx_queue;
>> -
>>  	PMD_INIT_FUNC_TRACE();
>>
>> -	if (rxq)
>> -		rte_free(rxq);
>> +	rte_free(rx_queue);
>>  }
>>
>>  static int
>> @@ -1087,9 +1084,9 @@ nicvf_dev_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qidx,
>>  		PMD_DRV_LOG(WARNING, "socket_id expected %d, configured %d",
>>  		socket_id, nic->node);
>>
>> -	/* Mempool memory should be contiguous */
>> -	if (mp->nb_mem_chunks != 1) {
>> -		PMD_INIT_LOG(ERR, "Non contiguous mempool, check huge page sz");
>> +	/* Mempool memory must be contiguous */
>> +	if (mp->flags & MEMPOOL_F_NO_PHYS_CONTIG) {
>
> If you need continuous memory, this check is not enough.
> Not having this flag doesn't guaranties that memory is continuous, this
> flag can be set but still can have multiple mem_chunks. And there is no
> guarantee that mem_chunks are continuous.

True, we need both checks:
	
	mp->nb_mem_chunks == 1 && !MEMPOOL_F_NO_PHYS_CONTIG.

Will fix in v2.

>
>> +		PMD_INIT_LOG(ERR, "Mempool memory must be contiguous");
>>  		return -EINVAL;
>>  	}
>>
>> @@ -1212,15 +1209,16 @@ nicvf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
>>  }
>>
>>  static nicvf_phys_addr_t
>> -rbdr_rte_mempool_get(void *opaque)
>> +rbdr_rte_mempool_get(void *dev, void *opaque)
>>  {
>>  	uint16_t qidx;
>>  	uintptr_t mbuf;
>>  	struct nicvf_rxq *rxq;
>> -	struct nicvf *nic = nicvf_pmd_priv((struct rte_eth_dev *)opaque);
>> +	struct rte_eth_dev *eth_dev = (struct rte_eth_dev *)dev;
>> +	struct nicvf *nic __rte_unused = (struct nicvf *)opaque;
>>
>> -	for (qidx = 0; qidx < nic->eth_dev->data->nb_rx_queues; qidx++) {
>> -		rxq = nic->eth_dev->data->rx_queues[qidx];
>> +	for (qidx = 0; qidx < eth_dev->data->nb_rx_queues; qidx++) {
>> +		rxq = eth_dev->data->rx_queues[qidx];
>>  		/* Maintain equal buffer count across all pools */
>>  		if (rxq->precharge_cnt >= rxq->qlen_mask)
>>  			continue;
>> @@ -1354,8 +1352,8 @@ nicvf_dev_start(struct rte_eth_dev *dev)
>>  	}
>>
>>  	/* Fill rte_mempool buffers in RBDR pool and precharge it */
>> -	ret = nicvf_qset_rbdr_precharge(nic, 0, rbdr_rte_mempool_get,
>> -					dev, total_rxq_desc);
>> +	ret = nicvf_qset_rbdr_precharge(dev, nic, 0, rbdr_rte_mempool_get,
>> +					total_rxq_desc);
>>  	if (ret) {
>>  		PMD_INIT_LOG(ERR, "Failed to fill rbdr %d", ret);
>>  		goto qset_rbdr_reclaim;
>> @@ -1721,12 +1719,6 @@ nicvf_eth_dev_init(struct rte_eth_dev *eth_dev)
>>  		goto malloc_fail;
>>  	}
>>
>> -	ret = nicvf_mbox_get_rss_size(nic);
>> -	if (ret) {
>> -		PMD_INIT_LOG(ERR, "Failed to get rss table size");
>> -		goto malloc_fail;
>> -	}
>> -
>
> Is removing mbox_get_rss_size() mentioned in commit log?

This chage remove spare function call but is not mentioned.
Will add a comment in v2.


>>  	PMD_INIT_LOG(INFO, "Port %d (%x:%x) mac=%02x:%02x:%02x:%02x:%02x:%02x",
>>  		eth_dev->data->port_id, nic->vendor_id, nic->device_id,
>>  		nic->mac_addr[0], nic->mac_addr[1], nic->mac_addr[2],
>>
>
>
>

^ permalink raw reply

* [PATCH v5 3/3] app/test_pmd: add tests for new API's
From: Bernard Iremonger @ 2016-09-29 14:16 UTC (permalink / raw)
  To: dev, rahul.r.shah, wenzhuo.lu, az5157; +Cc: Bernard Iremonger
In-Reply-To: <1474453204-31516-1-git-send-email-bernard.iremonger@intel.com>

add test for set vf vlan anti spoof
add test for set vf mac anti spoof
add test for set vf vlan stripq
add test for set vf vlan insert
add test for set tx loopback
add test for set all queues drop enable bit
add test for set vf split drop enable bit
add test for set vf mac address
add new API's to the testpmd guide

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 app/test-pmd/cmdline.c                      | 675 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  62 ++-
 2 files changed, 734 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 17d238f..2847f94 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -87,6 +87,7 @@
 #ifdef RTE_LIBRTE_PMD_BOND
 #include <rte_eth_bond.h>
 #endif
+#include <rte_pmd_ixgbe.h>
 
 #include "testpmd.h"
 
@@ -10585,6 +10586,672 @@ cmdline_parse_inst_t cmd_config_e_tag_filter_del = {
 	},
 };
 
+/* vf vlan anti spoof configuration */
+
+/* Common result structure for vf vlan anti spoof */
+struct cmd_vf_vlan_anti_spoof_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t vf;
+	cmdline_fixed_string_t vlan;
+	cmdline_fixed_string_t antispoof;
+	uint8_t port_id;
+	uint32_t vf_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf vlan anti spoof enable disable */
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_anti_spoof_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vf =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_anti_spoof_result,
+		 vf, "vf");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_vlan =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_anti_spoof_result,
+		 vlan, "vlan");
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_antispoof =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_anti_spoof_result,
+		 antispoof, "antispoof");
+cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_vlan_anti_spoof_result,
+		 port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_vlan_anti_spoof_vf_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_vlan_anti_spoof_result,
+		 vf_id, UINT32);
+cmdline_parse_token_string_t cmd_vf_vlan_anti_spoof_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_anti_spoof_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_vf_vlan_anti_spoof_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_vf_vlan_anti_spoof_result *res = parsed_result;
+	int ret = 0;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_pmd_ixgbe_set_vf_vlan_anti_spoof(res->port_id, res->vf_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid vf_id %d\n", res->vf_id);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = {
+	.f = cmd_set_vf_vlan_anti_spoof_parsed,
+	.data = NULL,
+	.help_str = "set vf vlan antispoof port_id vf_id on|off",
+	.tokens = {
+		(void *)&cmd_vf_vlan_anti_spoof_set,
+		(void *)&cmd_vf_vlan_anti_spoof_vf,
+		(void *)&cmd_vf_vlan_anti_spoof_vlan,
+		(void *)&cmd_vf_vlan_anti_spoof_antispoof,
+		(void *)&cmd_vf_vlan_anti_spoof_port_id,
+		(void *)&cmd_vf_vlan_anti_spoof_vf_id,
+		(void *)&cmd_vf_vlan_anti_spoof_on_off,
+		NULL,
+	},
+};
+
+/* vf mac anti spoof configuration */
+
+/* Common result structure for vf mac anti spoof */
+struct cmd_vf_mac_anti_spoof_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t vf;
+	cmdline_fixed_string_t mac;
+	cmdline_fixed_string_t antispoof;
+	uint8_t port_id;
+	uint32_t vf_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf mac anti spoof enable disable */
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_mac_anti_spoof_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_vf =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_mac_anti_spoof_result,
+		 vf, "vf");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_mac =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_mac_anti_spoof_result,
+		 mac, "mac");
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_antispoof =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_mac_anti_spoof_result,
+		 antispoof, "antispoof");
+cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_mac_anti_spoof_result,
+		 port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_mac_anti_spoof_vf_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_mac_anti_spoof_result,
+		 vf_id, UINT32);
+cmdline_parse_token_string_t cmd_vf_mac_anti_spoof_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_mac_anti_spoof_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_vf_mac_anti_spoof_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_vf_mac_anti_spoof_result *res = parsed_result;
+	int ret;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_pmd_ixgbe_set_vf_mac_anti_spoof(res->port_id, res->vf_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_vf_mac_anti_spoof = {
+	.f = cmd_set_vf_mac_anti_spoof_parsed,
+	.data = NULL,
+	.help_str = "set vf mac antispoof port_id vf_id on|off",
+	.tokens = {
+		(void *)&cmd_vf_mac_anti_spoof_set,
+		(void *)&cmd_vf_mac_anti_spoof_vf,
+		(void *)&cmd_vf_mac_anti_spoof_mac,
+		(void *)&cmd_vf_mac_anti_spoof_antispoof,
+		(void *)&cmd_vf_mac_anti_spoof_port_id,
+		(void *)&cmd_vf_mac_anti_spoof_vf_id,
+		(void *)&cmd_vf_mac_anti_spoof_on_off,
+		NULL,
+	},
+};
+
+/* vf vlan strip queue configuration */
+
+/* Common result structure for vf mac anti spoof */
+struct cmd_vf_vlan_stripq_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t vf;
+	cmdline_fixed_string_t vlan;
+	cmdline_fixed_string_t stripq;
+	uint8_t port_id;
+	uint16_t vf_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf vlan strip enable disable */
+cmdline_parse_token_string_t cmd_vf_vlan_stripq_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_stripq_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_vf_vlan_stripq_vf =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_stripq_result,
+		 vf, "vf");
+cmdline_parse_token_string_t cmd_vf_vlan_stripq_vlan =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_stripq_result,
+		 vlan, "vlan");
+cmdline_parse_token_string_t cmd_vf_vlan_stripq_stripq =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_stripq_result,
+		 stripq, "stripq");
+cmdline_parse_token_num_t cmd_vf_vlan_stripq_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_vlan_stripq_result,
+		 port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_vlan_stripq_vf_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_vlan_stripq_result,
+		 vf_id, UINT16);
+cmdline_parse_token_string_t cmd_vf_vlan_stripq_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_stripq_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_vf_vlan_stripq_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_vf_vlan_stripq_result *res = parsed_result;
+	int ret = 0;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_eth_dev_set_vf_vlan_stripq(res->port_id, res->vf_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_vf_vlan_stripq = {
+	.f = cmd_set_vf_vlan_stripq_parsed,
+	.data = NULL,
+	.help_str = "set vf vlan stripq port_id vf_id on|off",
+	.tokens = {
+		(void *)&cmd_vf_vlan_stripq_set,
+		(void *)&cmd_vf_vlan_stripq_vf,
+		(void *)&cmd_vf_vlan_stripq_vlan,
+		(void *)&cmd_vf_vlan_stripq_stripq,
+		(void *)&cmd_vf_vlan_stripq_port_id,
+		(void *)&cmd_vf_vlan_stripq_vf_id,
+		(void *)&cmd_vf_vlan_stripq_on_off,
+		NULL,
+	},
+};
+
+/* vf vlan insert configuration */
+
+/* Common result structure for vf vlan insert */
+struct cmd_vf_vlan_insert_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t vf;
+	cmdline_fixed_string_t vlan;
+	cmdline_fixed_string_t insert;
+	uint8_t port_id;
+	uint16_t vf_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf vlan insert enable disable */
+cmdline_parse_token_string_t cmd_vf_vlan_insert_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_insert_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_vf_vlan_insert_vf =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_insert_result,
+		 vf, "vf");
+cmdline_parse_token_string_t cmd_vf_vlan_insert_vlan =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_insert_result,
+		 vlan, "vlan");
+cmdline_parse_token_string_t cmd_vf_vlan_insert_insert =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_insert_result,
+		 insert, "insert");
+cmdline_parse_token_num_t cmd_vf_vlan_insert_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_vlan_insert_result,
+		 port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_vlan_insert_vf_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_vlan_insert_result,
+		 vf_id, UINT16);
+cmdline_parse_token_string_t cmd_vf_vlan_insert_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_vlan_insert_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_vf_vlan_insert_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_vf_vlan_insert_result *res = parsed_result;
+	int ret;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_pmd_ixgbe_set_vf_vlan_insert(res->port_id, res->vf_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_vf_vlan_insert = {
+	.f = cmd_set_vf_vlan_insert_parsed,
+	.data = NULL,
+	.help_str = "set vf vlan insert port_id vf_id on|off",
+	.tokens = {
+		(void *)&cmd_vf_vlan_insert_set,
+		(void *)&cmd_vf_vlan_insert_vf,
+		(void *)&cmd_vf_vlan_insert_vlan,
+		(void *)&cmd_vf_vlan_insert_insert,
+		(void *)&cmd_vf_vlan_insert_port_id,
+		(void *)&cmd_vf_vlan_insert_vf_id,
+		(void *)&cmd_vf_vlan_insert_on_off,
+		NULL,
+	},
+};
+
+/* tx loopback configuration */
+
+/* Common result structure for tx loopback */
+struct cmd_tx_loopback_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t tx;
+	cmdline_fixed_string_t loopback;
+	uint8_t port_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for tx loopback enable disable */
+cmdline_parse_token_string_t cmd_tx_loopback_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_tx_loopback_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_tx_loopback_tx =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_tx_loopback_result,
+		 tx, "tx");
+cmdline_parse_token_string_t cmd_tx_loopback_loopback =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_tx_loopback_result,
+		 loopback, "loopback");
+cmdline_parse_token_num_t cmd_tx_loopback_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_tx_loopback_result,
+		 port_id, UINT8);
+cmdline_parse_token_string_t cmd_tx_loopback_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_tx_loopback_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_tx_loopback_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_tx_loopback_result *res = parsed_result;
+	int ret;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_pmd_ixgbe_set_tx_loopback(res->port_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid is_on %d\n", is_on);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_tx_loopback = {
+	.f = cmd_set_tx_loopback_parsed,
+	.data = NULL,
+	.help_str = "set tx loopback port_id on|off",
+	.tokens = {
+		(void *)&cmd_tx_loopback_set,
+		(void *)&cmd_tx_loopback_tx,
+		(void *)&cmd_tx_loopback_loopback,
+		(void *)&cmd_tx_loopback_port_id,
+		(void *)&cmd_tx_loopback_on_off,
+		NULL,
+	},
+};
+
+/* all queues drop enable configuration */
+
+/* Common result structure for all queues drop enable */
+struct cmd_all_queues_drop_en_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t all;
+	cmdline_fixed_string_t queues;
+	cmdline_fixed_string_t drop;
+	uint8_t port_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for tx loopback enable disable */
+cmdline_parse_token_string_t cmd_all_queues_drop_en_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_all_queues_drop_en_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_all_queues_drop_en_all =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_all_queues_drop_en_result,
+		 all, "all");
+cmdline_parse_token_string_t cmd_all_queues_drop_en_queues =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_all_queues_drop_en_result,
+		 queues, "queues");
+cmdline_parse_token_string_t cmd_all_queues_drop_en_drop =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_all_queues_drop_en_result,
+		 drop, "drop");
+cmdline_parse_token_num_t cmd_all_queues_drop_en_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_all_queues_drop_en_result,
+		 port_id, UINT8);
+cmdline_parse_token_string_t cmd_all_queues_drop_en_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_all_queues_drop_en_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_all_queues_drop_en_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_all_queues_drop_en_result *res = parsed_result;
+	int ret = 0;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_pmd_ixgbe_set_all_queues_drop_en(res->port_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid is_on %d\n", is_on);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_all_queues_drop_en = {
+	.f = cmd_set_all_queues_drop_en_parsed,
+	.data = NULL,
+	.help_str = "set all queues drop port_id on|off",
+	.tokens = {
+		(void *)&cmd_all_queues_drop_en_set,
+		(void *)&cmd_all_queues_drop_en_all,
+		(void *)&cmd_all_queues_drop_en_queues,
+		(void *)&cmd_all_queues_drop_en_drop,
+		(void *)&cmd_all_queues_drop_en_port_id,
+		(void *)&cmd_all_queues_drop_en_on_off,
+		NULL,
+	},
+};
+
+/* vf split drop enable configuration */
+
+/* Common result structure for vf split drop enable */
+struct cmd_vf_split_drop_en_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t vf;
+	cmdline_fixed_string_t split;
+	cmdline_fixed_string_t drop;
+	uint8_t port_id;
+	uint16_t vf_id;
+	cmdline_fixed_string_t on_off;
+};
+
+/* Common CLI fields for vf split drop enable disable */
+cmdline_parse_token_string_t cmd_vf_split_drop_en_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_split_drop_en_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_vf_split_drop_en_vf =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_split_drop_en_result,
+		 vf, "vf");
+cmdline_parse_token_string_t cmd_vf_split_drop_en_split =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_split_drop_en_result,
+		 split, "split");
+cmdline_parse_token_string_t cmd_vf_split_drop_en_drop =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_split_drop_en_result,
+		 drop, "drop");
+cmdline_parse_token_num_t cmd_vf_split_drop_en_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_split_drop_en_result,
+		 port_id, UINT8);
+cmdline_parse_token_num_t cmd_vf_split_drop_en_vf_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_vf_split_drop_en_result,
+		 vf_id, UINT16);
+cmdline_parse_token_string_t cmd_vf_split_drop_en_on_off =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_vf_split_drop_en_result,
+		 on_off, "on#off");
+
+static void
+cmd_set_vf_split_drop_en_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_vf_split_drop_en_result *res = parsed_result;
+	int ret;
+	int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0;
+
+	ret = rte_pmd_ixgbe_set_vf_split_drop_en(res->port_id, res->vf_id, is_on);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid vf_id %d or is_on %d\n", res->vf_id, is_on);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_vf_split_drop_en = {
+	.f = cmd_set_vf_split_drop_en_parsed,
+	.data = NULL,
+	.help_str = "set vf split drop port_id vf_id on|off",
+	.tokens = {
+		(void *)&cmd_vf_split_drop_en_set,
+		(void *)&cmd_vf_split_drop_en_vf,
+		(void *)&cmd_vf_split_drop_en_split,
+		(void *)&cmd_vf_split_drop_en_drop,
+		(void *)&cmd_vf_split_drop_en_port_id,
+		(void *)&cmd_vf_split_drop_en_vf_id,
+		(void *)&cmd_vf_split_drop_en_on_off,
+		NULL,
+	},
+};
+
+/* vf mac address configuration */
+
+/* Common result structure for vf mac address */
+struct cmd_set_vf_mac_addr_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t vf;
+	cmdline_fixed_string_t mac;
+	cmdline_fixed_string_t addr;
+	uint8_t port_id;
+	uint16_t vf_id;
+	struct ether_addr mac_addr;
+
+};
+
+/* Common CLI fields for vf split drop enable disable */
+cmdline_parse_token_string_t cmd_set_vf_mac_addr_set =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_vf_mac_addr_result,
+		 set, "set");
+cmdline_parse_token_string_t cmd_set_vf_mac_addr_vf =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_vf_mac_addr_result,
+		 vf, "vf");
+cmdline_parse_token_string_t cmd_set_vf_mac_addr_mac =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_vf_mac_addr_result,
+		 mac, "mac");
+cmdline_parse_token_string_t cmd_set_vf_mac_addr_addr =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_set_vf_mac_addr_result,
+		 addr, "addr");
+cmdline_parse_token_num_t cmd_set_vf_mac_addr_port_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_vf_mac_addr_result,
+		 port_id, UINT8);
+cmdline_parse_token_num_t cmd_set_vf_mac_addr_vf_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_set_vf_mac_addr_result,
+		 vf_id, UINT16);
+cmdline_parse_token_etheraddr_t cmd_set_vf_mac_addr_mac_addr =
+	TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_mac_addr_result,
+		 mac_addr);
+
+static void
+cmd_set_vf_mac_addr_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_set_vf_mac_addr_result *res = parsed_result;
+	int ret;
+
+	ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id, &res->mac_addr);
+	switch (ret) {
+	case 0:
+		break;
+	case -EINVAL:
+		printf("invalid vf_id %d or mac_addr\n", res->vf_id);
+		break;
+	case -ENODEV:
+		printf("invalid port_id %d\n", res->port_id);
+		break;
+	default:
+		printf("programming error: (%s)\n", strerror(-ret));
+	}
+}
+
+cmdline_parse_inst_t cmd_set_vf_mac_addr = {
+	.f = cmd_set_vf_mac_addr_parsed,
+	.data = NULL,
+	.help_str = "set vf mac addr port_id vf_id xx:xx:xx:xx:xx:xx",
+	.tokens = {
+		(void *)&cmd_set_vf_mac_addr_set,
+		(void *)&cmd_set_vf_mac_addr_vf,
+		(void *)&cmd_set_vf_mac_addr_mac,
+		(void *)&cmd_set_vf_mac_addr_addr,
+		(void *)&cmd_set_vf_mac_addr_port_id,
+		(void *)&cmd_set_vf_mac_addr_vf_id,
+		(void *)&cmd_set_vf_mac_addr_mac_addr,
+		NULL,
+	},
+};
+
+
+/* get PMD dev_ops handle */
+
+/* Common result structure for vf mac address */
+struct cmd_get_pmd_handle_result {
+	cmdline_fixed_string_t get;
+	cmdline_fixed_string_t pmd;
+	cmdline_fixed_string_t handle;
+	uint8_t port_id;
+};
+
+
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -10739,6 +11406,14 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_config_e_tag_forwarding_en_dis,
 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add,
 	(cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del,
+	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof,
+	(cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof,
+	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq,
+	(cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert,
+	(cmdline_parse_inst_t *)&cmd_set_tx_loopback,
+	(cmdline_parse_inst_t *)&cmd_set_all_queues_drop_en,
+	(cmdline_parse_inst_t *)&cmd_set_vf_split_drop_en,
+	(cmdline_parse_inst_t *)&cmd_set_vf_mac_addr,
 	NULL,
 };
 
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index f87e0c2..145c425 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1,5 +1,5 @@
 ..  BSD LICENSE
-    Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+    Copyright(c) 2010-2016 Intel Corporation. All rights reserved.
     All rights reserved.
 
     Redistribution and use in source and binary forms, with or without
@@ -473,6 +473,34 @@ For example, to change the port forwarding:
    RX P=1/Q=0 (socket 0) -> TX P=3/Q=0 (socket 0) peer=02:00:00:00:00:03
    RX P=3/Q=0 (socket 0) -> TX P=1/Q=0 (socket 0) peer=02:00:00:00:00:02
 
+set tx loopback
+~~~~~~~~~~~~~~~
+
+Enable/disable tx loopback::
+
+   testpmd> set tx loopback (port_id) (on|off)
+
+set drop enable
+~~~~~~~~~~~~~~~
+
+set drop enable bit for all queues::
+
+   testpmd> set all queues drop (port_id) (on|off)
+
+set split drop enable (for VF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+set split drop enable bit for VF from PF::
+
+   testpmd> set vf split drop (port_id) (vf_id) (on|off)
+
+set mac antispoof (for VF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set mac antispoof for a VF from the PF::
+
+   testpmd> set vf mac antispoof  (port_id) (vf_id) (on|off)
+
 vlan set strip
 ~~~~~~~~~~~~~~
 
@@ -487,6 +515,27 @@ Set the VLAN strip for a queue on a port::
 
    testpmd> vlan set stripq (on|off) (port_id,queue_id)
 
+vlan set stripq (for VF)
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set VLAN strip for all queues in a pool for a VF from the PF::
+
+   testpmd> set vf vlan stripq (port_id) (vf_id) (on|off)
+
+vlan set insert (for VF)
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set VLAN insert for a VF from the PF::
+
+   testpmd> set vf vlan insert (port_id) (vf_id) (on|off)
+
+vlan set antispoof (for VF)
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Set VLAN antispoof for a VF from the PF::
+
+   testpmd> set vf vlan antispoof (port_id) (vf_id) (on|off)
+
 vlan set filter
 ~~~~~~~~~~~~~~~
 
@@ -727,13 +776,20 @@ Remove a MAC address from a port::
 
    testpmd> mac_addr remove (port_id) (XX:XX:XX:XX:XX:XX)
 
-mac_addr add(for VF)
-~~~~~~~~~~~~~~~~~~~~
+mac_addr add (for VF)
+~~~~~~~~~~~~~~~~~~~~~
 
 Add an alternative MAC address for a VF to a port::
 
    testpmd> mac_add add port (port_id) vf (vf_id) (XX:XX:XX:XX:XX:XX)
 
+mac_addr set (for VF)
+~~~~~~~~~~~~~~~~~~~~~
+
+Set the MAC address for a VF from the PF::
+
+   testpmd> set vf mac addr (port_id) (vf_id) (XX:XX:XX:XX:XX:XX)
+
 set port-uta
 ~~~~~~~~~~~~
 
-- 
2.9.0

^ permalink raw reply related

* [PATCH v5 2/3] net/ixgbe: add API's for VF management
From: Bernard Iremonger @ 2016-09-29 14:16 UTC (permalink / raw)
  To: dev, rahul.r.shah, wenzhuo.lu, az5157; +Cc: Bernard Iremonger, azelezniak
In-Reply-To: <1474453204-31516-1-git-send-email-bernard.iremonger@intel.com>

Add API's to configure and manage VF's on an Intel 82559 NIC.

add rte_pmd_ixgbe_set_vf_vlan_anti_spoof function.
add rte_pmd_ixgbe_set_vf_mac_anti_spoof function.

Signed-off-by: azelezniak <alexz@att.com>

add rte_pmd_ixgbe_set_vf_vlan_insert function.
add rte_pmd_ixgbe_set_tx_loopback function.
add rte_pmd_ixgbe_set_all_queues_drop function.
add rte_pmd_ixgbe_set_vf_split_drop_en function.
add rte_pmd_ixgbe_set_vf_mac_addr function.

Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 drivers/net/ixgbe/Makefile                  |   2 +
 drivers/net/ixgbe/ixgbe_ethdev.c            | 200 ++++++++++++++++++++++++++++
 drivers/net/ixgbe/rte_pmd_ixgbe.h           | 162 ++++++++++++++++++++++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  12 ++
 4 files changed, 376 insertions(+)
 create mode 100644 drivers/net/ixgbe/rte_pmd_ixgbe.h

diff --git a/drivers/net/ixgbe/Makefile b/drivers/net/ixgbe/Makefile
index a6c71f3..7493b8d 100644
--- a/drivers/net/ixgbe/Makefile
+++ b/drivers/net/ixgbe/Makefile
@@ -119,6 +119,8 @@ SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_bypass.c
 SRCS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += ixgbe_82599_bypass.c
 endif
 
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_ACL)-include := rte_pmd_ixgbe.h
 
 # this lib depends upon:
 DEPDIRS-$(CONFIG_RTE_LIBRTE_IXGBE_PMD) += lib/librte_eal lib/librte_ether
diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c
index 73a406b..beaebe1 100644
--- a/drivers/net/ixgbe/ixgbe_ethdev.c
+++ b/drivers/net/ixgbe/ixgbe_ethdev.c
@@ -72,6 +72,8 @@
 #include "base/ixgbe_phy.h"
 #include "ixgbe_regs.h"
 
+#include "rte_pmd_ixgbe.h"
+
 /*
  * High threshold controlling when to start sending XOFF frames. Must be at
  * least 8 bytes less than receive packet buffer size. This value is in units
@@ -4068,6 +4070,35 @@ ixgbe_set_default_mac_addr(struct rte_eth_dev *dev, struct ether_addr *addr)
 	ixgbe_add_rar(dev, addr, 0, 0);
 }
 
+int
+rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port, uint16_t vf, struct ether_addr *mac_addr)
+{
+	struct ixgbe_hw *hw;
+	struct ixgbe_vf_info *vfinfo;
+	int rar_entry;
+	uint8_t *new_mac = (uint8_t *)(mac_addr);
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	rte_eth_dev_info_get(port, &dev_info);
+
+	if (vf >= dev_info.max_vfs)
+		return -EINVAL;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));
+	rar_entry = hw->mac.num_rar_entries - (vf + 1);
+
+	if (is_valid_assigned_ether_addr((struct ether_addr *)new_mac)) {
+		rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac, ETHER_ADDR_LEN);
+		return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf, IXGBE_RAH_AV);
+	}
+	return -EINVAL;
+}
+
 static int
 ixgbe_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
 {
@@ -4661,6 +4692,175 @@ ixgbe_set_pool_vlan_filter(struct rte_eth_dev *dev, uint16_t vlan,
 	return ret;
 }
 
+int
+rte_pmd_ixgbe_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
+{
+	struct ixgbe_hw *hw;
+	struct ixgbe_mac_info *mac;
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	rte_eth_dev_info_get(port, &dev_info);
+
+	if (vf >= dev_info.max_vfs)
+		return -EINVAL;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	mac = &hw->mac;
+
+	mac->ops.set_vlan_anti_spoofing(hw, on, vf);
+
+	return 0;
+}
+
+int
+rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on)
+{
+	struct ixgbe_hw *hw;
+	struct ixgbe_mac_info *mac;
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	rte_eth_dev_info_get(port, &dev_info);
+
+	if (vf >= dev_info.max_vfs)
+		return -EINVAL;
+
+	if (on > 1)
+		return -EINVAL;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	mac = &hw->mac;
+	mac->ops.set_mac_anti_spoofing(hw, on, vf);
+
+	return 0;
+}
+
+int
+rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf, uint8_t on)
+{
+	struct ixgbe_hw *hw;
+	uint32_t ctrl;
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	rte_eth_dev_info_get(port, &dev_info);
+
+	if (vf >= dev_info.max_vfs)
+		return -EINVAL;
+
+	if (on > 1)
+		return -EINVAL;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	ctrl = IXGBE_READ_REG(hw, IXGBE_VMVIR(vf));
+	if (on) {
+		ctrl = on;
+		ctrl |= IXGBE_VMVIR_VLANA_DEFAULT;
+	} else {
+		ctrl = 0;
+	}
+
+	IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), ctrl);
+
+	return 0;
+}
+
+int
+rte_pmd_ixgbe_set_tx_loopback(uint8_t port, uint8_t on)
+{
+	struct ixgbe_hw *hw;
+	uint32_t ctrl;
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (on > 1)
+		return -EINVAL;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	ctrl = IXGBE_READ_REG(hw, IXGBE_PFDTXGSWC);
+	/* enable or disable VMDQ loopback */
+	if (on)
+		ctrl |= IXGBE_PFDTXGSWC_VT_LBEN;
+	else
+		ctrl &= ~IXGBE_PFDTXGSWC_VT_LBEN;
+
+	IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, ctrl);
+
+	return 0;
+}
+
+int
+rte_pmd_ixgbe_set_all_queues_drop_en(uint8_t port, uint8_t on)
+{
+	struct ixgbe_hw *hw;
+	uint32_t reg_value;
+	int i;
+	int num_queues = (int)(IXGBE_QDE_IDX_MASK >> IXGBE_QDE_IDX_SHIFT);
+	struct rte_eth_dev *dev;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+
+	if (on > 1)
+		return -EINVAL;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	for (i = 0; i <= num_queues; i++) {
+		reg_value = IXGBE_QDE_WRITE |
+				(i << IXGBE_QDE_IDX_SHIFT) |
+				(on & IXGBE_QDE_ENABLE);
+		IXGBE_WRITE_REG(hw, IXGBE_QDE, reg_value);
+	}
+
+	return 0;
+}
+
+int
+rte_pmd_ixgbe_set_vf_split_drop_en(uint8_t port, uint16_t vf, uint8_t on)
+{
+	struct ixgbe_hw *hw;
+	uint32_t reg_value;
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
+
+	dev = &rte_eth_devices[port];
+	rte_eth_dev_info_get(port, &dev_info);
+
+	/* only support VF's 0 to 63 */
+	if ((vf >= dev_info.max_vfs) || (vf > 63))
+		return -EINVAL;
+
+	if (on > 1)
+		return -EINVAL;
+
+	hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
+	reg_value = IXGBE_READ_REG(hw, IXGBE_SRRCTL(vf));
+	if (on)
+		reg_value |= IXGBE_SRRCTL_DROP_EN;
+	else
+		reg_value &= ~IXGBE_SRRCTL_DROP_EN;
+
+	IXGBE_WRITE_REG(hw, IXGBE_SRRCTL(vf), reg_value);
+
+	return 0;
+}
+
 #define IXGBE_MRCTL_VPME  0x01 /* Virtual Pool Mirroring. */
 #define IXGBE_MRCTL_UPME  0x02 /* Uplink Port Mirroring. */
 #define IXGBE_MRCTL_DPME  0x04 /* Downlink Port Mirroring. */
diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe.h b/drivers/net/ixgbe/rte_pmd_ixgbe.h
new file mode 100644
index 0000000..918540b
--- /dev/null
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe.h
@@ -0,0 +1,162 @@
+/*-
+ *   BSD LICENSE
+ *
+ *   Copyright (c) 2016 Intel Corporation. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may be used to endorse or promote products derived
+ *       from this software without specific prior written permission.
+ *
+ *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file rte_pmd_ixgbe.h
+ * ixgbe PMD specific functions.
+ *
+ **/
+
+#ifndef _PMD_IXGBE_H_
+#define _PMD_IXGBE_H_
+
+#include <rte_ethdev.h>
+
+/**
+ * Set the VF MAC address.
+ *
+ * @param port
+ *   The port identifier of the Ethernet device.
+ * @param vf
+ *   VF id.
+ * @param mac_addr
+ *   VF MAC address.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
+ */
+int rte_pmd_ixgbe_set_vf_mac_addr(uint8_t port, uint16_t vf, struct ether_addr *mac_addr);
+
+/**
+ * Enable/Disable VF VLAN anti spoofing.
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param vf
+ *    VF on which to set VLAN anti spoofing.
+ * @param on
+ *    1 - Enable VFs VLAN anti spoofing.
+ *    0 - Disable VFs VLAN anti spoofing.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_ixgbe_set_vf_vlan_anti_spoof(uint8_t port, uint16_t vf, uint8_t on);
+
+/**
+ * Enable/Disable VF MAC anti spoofing.
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param vf
+ *    VF on which to set MAC anti spoofing.
+ * @param on
+ *    1 - Enable VFs MAC anti spoofing.
+ *    0 - Disable VFs MAC anti spoofing.
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_ixgbe_set_vf_mac_anti_spoof(uint8_t port, uint16_t vf, uint8_t on);
+
+/**
+ * Enable/Disable vf vlan insert
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param vf
+ *    ID specifying VF.
+ * @param on
+ *    1 - Enable VF's vlan insert.
+ *    0 - Disable VF's vlan insert
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_ixgbe_set_vf_vlan_insert(uint8_t port, uint16_t vf,	uint8_t on);
+
+/**
+ * Enable/Disable tx loopback
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param on
+ *    1 - Enable tx loopback.
+ *    0 - Disable tx loopback.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_ixgbe_set_tx_loopback(uint8_t port, uint8_t on);
+
+/**
+ * set all queues drop enable bit
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param on
+ *    1 - set the queue drop enable bit for all pools.
+ *    0 - reset the queue drop enable bit for all pools.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int rte_pmd_ixgbe_set_all_queues_drop_en(uint8_t port, uint8_t on);
+
+/**
+ * set drop enable bit in the VF split rx control register
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param vf
+ *    ID specifying VF.
+ * @param on
+ *    1 - set the drop enable bit in the split rx control register.
+ *    0 - reset the drop enable bit in the split rx control register.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+
+int rte_pmd_ixgbe_set_vf_split_drop_en(uint8_t port, uint16_t vf, uint8_t on);
+#endif /* _PMD_IXGBE_H_ */
diff --git a/drivers/net/ixgbe/rte_pmd_ixgbe_version.map b/drivers/net/ixgbe/rte_pmd_ixgbe_version.map
index ef35398..7677885 100644
--- a/drivers/net/ixgbe/rte_pmd_ixgbe_version.map
+++ b/drivers/net/ixgbe/rte_pmd_ixgbe_version.map
@@ -2,3 +2,15 @@ DPDK_2.0 {
 
 	local: *;
 };
+
+DPDK_16.11 {
+	global:
+
+	rte_pmd_ixgbe_set_all_queues_drop_en;
+	rte_pmd_ixgbe_set_tx_loopback;
+	rte_pmd_ixgbe_set_vf_mac_addr;
+	rte_pmd_ixgbe_set_vf_mac_anti_spoof;
+	rte_pmd_ixgbe_set_vf_split_drop_en;
+	rte_pmd_ixgbe_set_vf_vlan_anti_spoof;
+	rte_pmd_ixgbe_set_vf_vlan_insert;
+} DPDK_2.0;
-- 
2.9.0

^ permalink raw reply related

* [PATCH v5 0/3] add API's for VF management
From: Bernard Iremonger @ 2016-09-29 14:16 UTC (permalink / raw)
  To: dev, rahul.r.shah, wenzhuo.lu, az5157; +Cc: Bernard Iremonger
In-Reply-To: <1474453204-31516-1-git-send-email-bernard.iremonger@intel.com>

This patchset contains new DPDK API's requested by AT&T for use
with the Virtual Function Daemon (VFD).

The need to configure and manage VF's on a NIC has grown to the
point where AT&T have devloped a DPDK based tool, VFD, to do this.

This patch set adds API extensions to DPDK VF configuration.

Eight new API's have been added for the Intel 82559 NIC.

Changes have been made to testpmd to facilitate testing of the new API's.
The testpmd documentation has been updated to document the testpmd changes.

Changes in v5:
rebase to latest master branch.
remove new API's from eth_dev_ops structure.
add public API's to ixgbe PMD.
revise testpmd commands for new API's

Changes in v4:
The rte_eth_dev_vf_ping API has been dropped as it is a work around for a bug.
The rte_eth_dev_set_vf_vlan_strip API has been renamed to
rte_eth_dev_set_vf_vlan_stripq.

Changes in v3:
rebase to latest master branch.
drop patches for callback functions
revise VF id checks in new librte_ether functions
revise testpmd commands for new API's

Changes in V2:
rebase to latest master branch.
fix compile  error with clang.

Bernard Iremonger (3):
  librte_ether: add API for VF management
  net/ixgbe: add API's for VF management
  app/test_pmd: add tests for new API's

 app/test-pmd/cmdline.c                      | 675 ++++++++++++++++++++++++++++
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  62 ++-
 drivers/net/ixgbe/Makefile                  |   2 +
 drivers/net/ixgbe/ixgbe_ethdev.c            | 200 +++++++++
 drivers/net/ixgbe/rte_pmd_ixgbe.h           | 162 +++++++
 drivers/net/ixgbe/rte_pmd_ixgbe_version.map |  12 +
 lib/librte_ether/rte_ethdev.c               |  27 ++
 lib/librte_ether/rte_ethdev.h               |  23 +-
 lib/librte_ether/rte_ether_version.map      |   6 +
 9 files changed, 1165 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/ixgbe/rte_pmd_ixgbe.h

-- 
2.9.0

^ permalink raw reply

* [PATCH v5 1/3] librte_ether: add API for VF management
From: Bernard Iremonger @ 2016-09-29 14:16 UTC (permalink / raw)
  To: dev, rahul.r.shah, wenzhuo.lu, az5157; +Cc: Bernard Iremonger, azelezniak
In-Reply-To: <1474453204-31516-1-git-send-email-bernard.iremonger@intel.com>

Add new API function to configure and manage VF's on a NIC.

add rte_eth_dev_set_vf_vlan_stripq function.

Signed-off-by: azelezniak <alexz@att.com>
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
---
 lib/librte_ether/rte_ethdev.c          | 27 +++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h          | 23 ++++++++++++++++++++++-
 lib/librte_ether/rte_ether_version.map |  6 ++++++
 3 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 382c959..15e21ca 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -2489,6 +2489,33 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port_id, uint16_t vlan_id,
 						   vf_mask, vlan_on);
 }
 
+int
+rte_eth_dev_set_vf_vlan_stripq(uint8_t port_id, uint16_t vf, int on)
+{
+	struct rte_eth_dev *dev;
+	struct rte_eth_dev_info dev_info;
+	uint16_t queues_per_pool;
+	uint32_t q;
+
+	RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+
+	dev = &rte_eth_devices[port_id];
+	rte_eth_dev_info_get(port_id, &dev_info);
+
+	if (vf >= dev_info.max_vfs) {
+		RTE_PMD_DEBUG_TRACE("set VF vlan stripq: invalid VF %d\n", vf);
+		return -EINVAL;
+	}
+
+	RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->vlan_strip_queue_set, -ENOTSUP);
+
+	queues_per_pool = dev_info.vmdq_queue_num/dev_info.max_vmdq_pools;
+
+	for (q = 0; q < queues_per_pool; q++)
+		(*dev->dev_ops->vlan_strip_queue_set)(dev, q + vf * queues_per_pool, on);
+	return 0;
+}
+
 int rte_eth_set_queue_rate_limit(uint8_t port_id, uint16_t queue_idx,
 					uint16_t tx_rate)
 {
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 96575e8..fb2be45 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -3499,7 +3499,28 @@ rte_eth_dev_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
 				uint8_t vlan_on);
 
 /**
- * Set a traffic mirroring rule on an Ethernet device
+ * Enable/Disable vf vlan strip for all queues in a pool
+ *
+ * @param port
+ *    The port identifier of the Ethernet device.
+ * @param vf
+ *    ID specifying VF.
+ * @param on
+ *    1 - Enable VF's vlan strip on RX queues.
+ *    0 - Disable VF's vlan strip on RX queues.
+ * @param queues_per_pool
+ *    The number of queues per pool.
+ *
+ * @return
+ *   - (0) if successful.
+ *   - (-ENOTSUP) if hardware doesn't support this feature.
+ *   - (-ENODEV) if *port* invalid.
+ *   - (-EINVAL) if bad parameter.
+ */
+int
+rte_eth_dev_set_vf_vlan_stripq(uint8_t port, uint16_t vf, int on);
+
+/** Set a traffic mirroring rule on an Ethernet device
  *
  * @param port_id
  *   The port identifier of the Ethernet device.
diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map
index 45ddf44..ae44074 100644
--- a/lib/librte_ether/rte_ether_version.map
+++ b/lib/librte_ether/rte_ether_version.map
@@ -139,3 +139,9 @@ DPDK_16.07 {
 	rte_eth_dev_get_port_by_name;
 	rte_eth_xstats_get_names;
 } DPDK_16.04;
+
+DPDK_16.11 {
+	global:
+
+	rte_eth_dev_set_vf_vlan_stripq;
+} DPDK_16.07;
-- 
2.9.0

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox