-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmlx4_18_11.patch
131 lines (123 loc) · 4.14 KB
/
mlx4_18_11.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
From 454f1d6f852804214a5a1d56a53d0fe3ba786b08 Mon Sep 17 00:00:00 2001
From: Josh Fried <[email protected]>
Date: Sun, 13 Jan 2019 18:42:41 -0500
Subject: [PATCH] support manually registering memory for MLX4
---
drivers/net/mlx4/Makefile | 2 ++
drivers/net/mlx4/mlx4_custom.h | 8 ++++++++
drivers/net/mlx4/mlx4_mr.c | 17 +++++++++++++++++
drivers/net/mlx4/mlx4_rxtx.c | 2 +-
drivers/net/mlx4/mlx4_rxtx.h | 12 ++++++++++++
drivers/net/mlx4/rte_pmd_mlx4_version.map | 4 ++++
6 files changed, 44 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/mlx4/mlx4_custom.h
diff --git a/drivers/net/mlx4/Makefile b/drivers/net/mlx4/Makefile
index 92e932250..9308ce7ad 100644
--- a/drivers/net/mlx4/Makefile
+++ b/drivers/net/mlx4/Makefile
@@ -10,6 +10,8 @@ LIB_GLUE = $(LIB_GLUE_BASE).$(LIB_GLUE_VERSION)
LIB_GLUE_BASE = librte_pmd_mlx4_glue.so
LIB_GLUE_VERSION = 18.02.0
+SYMLINK-$(CONFIG_RTE_LIBRTE_MLX4_PMD)-include += mlx4_custom.h
+
# Sources.
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4.c
SRCS-$(CONFIG_RTE_LIBRTE_MLX4_PMD) += mlx4_ethdev.c
diff --git a/drivers/net/mlx4/mlx4_custom.h b/drivers/net/mlx4/mlx4_custom.h
new file mode 100644
index 000000000..93520da22
--- /dev/null
+++ b/drivers/net/mlx4/mlx4_custom.h
@@ -0,0 +1,8 @@
+
+#ifndef RTE_PMD_MLX4_CUSTOM_H
+#define RTE_PMD_MLX4_CUSTOM_H
+
+void *mlx4_manual_reg_mr(uint8_t port_id, void *addr, size_t length, uint32_t *lkey_out);
+void mlx4_manual_dereg_mr(void *ibv_mr);
+
+#endif /* RTE_PMD_MLX4_CUSTOM_H */
diff --git a/drivers/net/mlx4/mlx4_mr.c b/drivers/net/mlx4/mlx4_mr.c
index a0094483a..7314de77c 100644
--- a/drivers/net/mlx4/mlx4_mr.c
+++ b/drivers/net/mlx4/mlx4_mr.c
@@ -1358,3 +1358,20 @@ mlx4_mr_release(struct rte_eth_dev *dev)
/* Free all remaining MRs. */
mlx4_mr_garbage_collect(dev);
}
+
+void *
+mlx4_manual_reg_mr(uint8_t port_id, void *addr, size_t length, uint32_t *lkey_out)
+{
+ struct rte_eth_dev *dev = &rte_eth_devices[port_id];
+ struct priv *priv = dev->data->dev_private;
+ struct ibv_mr *ibv_mr = mlx4_glue->reg_mr(priv->pd, addr, length, IBV_ACCESS_LOCAL_WRITE);
+ if (ibv_mr && lkey_out) *lkey_out = rte_cpu_to_be_32(ibv_mr->lkey);
+
+ return ibv_mr;
+}
+
+void
+mlx4_manual_dereg_mr(void *ibv_mr)
+{
+ mlx4_glue->dereg_mr(ibv_mr);
+}
diff --git a/drivers/net/mlx4/mlx4_rxtx.c b/drivers/net/mlx4/mlx4_rxtx.c
index 8c88effcd..73917699d 100644
--- a/drivers/net/mlx4/mlx4_rxtx.c
+++ b/drivers/net/mlx4/mlx4_rxtx.c
@@ -949,7 +949,7 @@ mlx4_tx_burst(void *dpdk_txq, struct rte_mbuf **pkts, uint16_t pkts_n)
elt->buf = NULL;
break;
}
- lkey = mlx4_tx_mb2mr(txq, buf);
+ lkey = mlx4_tx_mb2mr_custom(buf);
if (unlikely(lkey == (uint32_t)-1)) {
/* MR does not exist. */
DEBUG("%p: unable to get MP <-> MR association",
diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h
index d7ec4e0c5..9a6605aeb 100644
--- a/drivers/net/mlx4/mlx4_rxtx.h
+++ b/drivers/net/mlx4/mlx4_rxtx.h
@@ -26,6 +26,7 @@
#include "mlx4.h"
#include "mlx4_prm.h"
#include "mlx4_mr.h"
+#include "mlx4_custom.h"
/** Rx queue counters. */
struct mlx4_rxq_stats {
@@ -165,6 +166,9 @@ uint32_t mlx4_rx_addr2mr_bh(struct rxq *rxq, uintptr_t addr);
uint32_t mlx4_tx_mb2mr_bh(struct txq *txq, struct rte_mbuf *mb);
uint32_t mlx4_tx_update_ext_mp(struct txq *txq, uintptr_t addr,
struct rte_mempool *mp);
+struct mem_info {
+ uint32_t lkey;
+};
/**
* Get Memory Pool (MP) from mbuf. If mbuf is indirect, the pool from which the
@@ -243,4 +247,12 @@ mlx4_tx_mb2mr(struct txq *txq, struct rte_mbuf *mb)
return mlx4_tx_mb2mr_bh(txq, mb);
}
+static __rte_always_inline uint32_t
+mlx4_tx_mb2mr_custom(struct rte_mbuf *mb)
+{
+ struct mem_info *m = (struct mem_info *)(((char *) mb) +
+ sizeof(struct rte_mbuf));
+ return m->lkey;
+}
+
#endif /* MLX4_RXTX_H_ */
diff --git a/drivers/net/mlx4/rte_pmd_mlx4_version.map b/drivers/net/mlx4/rte_pmd_mlx4_version.map
index ef3539840..b932c2621 100644
--- a/drivers/net/mlx4/rte_pmd_mlx4_version.map
+++ b/drivers/net/mlx4/rte_pmd_mlx4_version.map
@@ -1,4 +1,8 @@
DPDK_2.0 {
local: *;
+
+ global:
+ mlx4_manual_reg_mr;
+ mlx4_manual_dereg_mr;
};
--
2.17.1