[dpdk-dev,07/11] examples/ipsec-secgw: Fixed phyiscal address of aad

Message ID 1507987683-12315-7-git-send-email-aviadye@dev.mellanox.co.il (mailing list archive)
State Changes Requested, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Aviad Yehezkel Oct. 14, 2017, 1:27 p.m. UTC
  From: Aviad Yehezkel <aviadye@mellanox.com>

Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
---
 examples/ipsec-secgw/esp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
  

Comments

Aviad Yehezkel Oct. 15, 2017, 12:55 p.m. UTC | #1
On 10/14/2017 4:27 PM, aviadye@dev.mellanox.co.il wrote:
> From: Aviad Yehezkel <aviadye@mellanox.com>
>
> Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
> ---
>   examples/ipsec-secgw/esp.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/examples/ipsec-secgw/esp.c b/examples/ipsec-secgw/esp.c
> index 689e917..aa2233d 100644
> --- a/examples/ipsec-secgw/esp.c
> +++ b/examples/ipsec-secgw/esp.c
> @@ -355,8 +355,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
>   		aad = get_aad(m);
>   		memcpy(aad, esp, 8);
>   		sym_cop->aead.aad.data = aad;
> -		sym_cop->aead.aad.phys_addr = rte_pktmbuf_mtophys_offset(m,
> -				aad - rte_pktmbuf_mtod(m, uint8_t *));
> +		sym_cop->aead.aad.phys_addr = rte_mem_virt2phy(aad);
>   
>   		sym_cop->aead.digest.data = rte_pktmbuf_mtod_offset(m, uint8_t *,
>   			rte_pktmbuf_pkt_len(m) - sa->digest_len);

Tested-by: Aviad Yehezkel <aviadye@mellanox.com>
  
Sergio Gonzalez Monroy Oct. 16, 2017, 9:39 a.m. UTC | #2
On 14/10/2017 14:27, aviadye@dev.mellanox.co.il wrote:
> From: Aviad Yehezkel <aviadye@mellanox.com>
>
> Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
> ---
>   examples/ipsec-secgw/esp.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/examples/ipsec-secgw/esp.c b/examples/ipsec-secgw/esp.c
> index 689e917..aa2233d 100644
> --- a/examples/ipsec-secgw/esp.c
> +++ b/examples/ipsec-secgw/esp.c
> @@ -355,8 +355,7 @@ esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
>   		aad = get_aad(m);
>   		memcpy(aad, esp, 8);
>   		sym_cop->aead.aad.data = aad;
> -		sym_cop->aead.aad.phys_addr = rte_pktmbuf_mtophys_offset(m,
> -				aad - rte_pktmbuf_mtod(m, uint8_t *));
> +		sym_cop->aead.aad.phys_addr = rte_mem_virt2phy(aad);
>   

That function is very expensive and should not be used in data path.
You should use the phys_addr in the crypto_op to calculate proper value.

Thanks,
Sergio

>   		sym_cop->aead.digest.data = rte_pktmbuf_mtod_offset(m, uint8_t *,
>   			rte_pktmbuf_pkt_len(m) - sa->digest_len);
  

Patch

diff --git a/examples/ipsec-secgw/esp.c b/examples/ipsec-secgw/esp.c
index 689e917..aa2233d 100644
--- a/examples/ipsec-secgw/esp.c
+++ b/examples/ipsec-secgw/esp.c
@@ -355,8 +355,7 @@  esp_outbound(struct rte_mbuf *m, struct ipsec_sa *sa,
 		aad = get_aad(m);
 		memcpy(aad, esp, 8);
 		sym_cop->aead.aad.data = aad;
-		sym_cop->aead.aad.phys_addr = rte_pktmbuf_mtophys_offset(m,
-				aad - rte_pktmbuf_mtod(m, uint8_t *));
+		sym_cop->aead.aad.phys_addr = rte_mem_virt2phy(aad);
 
 		sym_cop->aead.digest.data = rte_pktmbuf_mtod_offset(m, uint8_t *,
 			rte_pktmbuf_pkt_len(m) - sa->digest_len);