diff options
-rw-r--r-- | docker/dmm_image/README.md | 13 | ||||
-rw-r--r-- | docker/dmm_image/centos/Dockerfile | 17 | ||||
-rw-r--r-- | src/framework/common/base/include/common/common_mem_buf.h | 4 | ||||
-rw-r--r-- | src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c | 15 | ||||
-rw-r--r-- | src/framework/lib_common_mem/common_buf.c | 24 | ||||
-rwxr-xr-x[-rw-r--r--] | stacks/lwip_stack/release/script/nstack_fun.sh | 4 | ||||
-rw-r--r-- | stacks/lwip_stack/release/script/nstack_var.sh | 2 | ||||
-rw-r--r-- | stacks/lwip_stack/src/io_adpt/dpdk.c | 100 |
8 files changed, 157 insertions, 22 deletions
diff --git a/docker/dmm_image/README.md b/docker/dmm_image/README.md new file mode 100644 index 0000000..0b674b2 --- /dev/null +++ b/docker/dmm_image/README.md @@ -0,0 +1,13 @@ +# How to build the image of dmm +Note: Make sure your computer can connect to the network +```sh + #cd dmm/docker/dmm_image/centos + #docker build -t "dmm:tag" . +``` + +# How to use the image of dmm +```sh + #docker run -i -t --network=host -v /sys/bus/pci/devices:/sys/bus/pci/devices -v /sys/devices/system/node:/sys/devices/system/node -v /mnt/nstackhuge:/mnt/nstackhuge -v /dev:/dev --privileged dmm:tag /bin/bash +``` + +Then we will enter a container and we can build dmm and run the app. diff --git a/docker/dmm_image/centos/Dockerfile b/docker/dmm_image/centos/Dockerfile new file mode 100644 index 0000000..de772fe --- /dev/null +++ b/docker/dmm_image/centos/Dockerfile @@ -0,0 +1,17 @@ +FROM docker.io/centos:latest + +RUN yum install -y git vim sudo ethtool + +RUN yum install -y kernel-devel-`uname -r` +RUN yum install -y kernel-`uname -r` + +RUN git config --global http.sslVerify false +RUN git config --global user.email "you@example.com" +RUN git config --global user.name "Your Name" + +RUN git clone https://gerrit.fd.io/r/dmm + +RUN mkdir -p /var/run/ip_module/ +RUN mkdir -p /var/log/nStack/ip_module/ + +RUN cd /dmm/scripts/ && bash -x build.sh && cd /dmm/ && git clean -dfx ./ && git checkout ./ diff --git a/src/framework/common/base/include/common/common_mem_buf.h b/src/framework/common/base/include/common/common_mem_buf.h index f9f1593..c9bb9fd 100644 --- a/src/framework/common/base/include/common/common_mem_buf.h +++ b/src/framework/common/base/include/common/common_mem_buf.h @@ -20,6 +20,7 @@ #ifdef HAL_LIB #else +#include "nsfw_mem_api.h" #include "common_mem_base_type.h" #include "types.h" @@ -64,7 +65,8 @@ typedef struct __common_pal_module_info * @param name * The name of the buf pool. */ -int nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode); +int nscomm_pal_module_init (nsfw_mem_para * para, + common_mem_pal_module_info * pinfo, u8 app_mode); void *nscomm_memzone_data_reserve_name (const char *name, size_t len, int socket_id); diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c index ba38c32..77ffd19 100644 --- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c +++ b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c @@ -73,18 +73,11 @@ nsfw_shmem_init (nsfw_mem_para * para) NSCOMM_LOGINF ("nsfw shmem init begin"); - if (NSFW_PROC_MAIN == para->enflag) - { - iret = common_pal_module_init (NULL, app_mode); - } - else - { - LCORE_MASK_SET (rteinfo.ilcoremask, 1); - rteinfo.ucproctype = DMM_PROC_T_SECONDARY; - iret = common_pal_module_init (&rteinfo, app_mode); - } + LCORE_MASK_SET (rteinfo.ilcoremask, 1); + rteinfo.ucproctype = DMM_PROC_T_SECONDARY; + iret = common_pal_module_init (para, &rteinfo, app_mode); - if (NSFW_MEM_OK != iret) + if (DMM_MBUF_RET_OK != iret) { NSCOMM_LOGERR ("rte init fail] ret=0x%x", iret); return NSFW_MEM_ERR; diff --git a/src/framework/lib_common_mem/common_buf.c b/src/framework/lib_common_mem/common_buf.c index 9d9a127..d31ca83 100644 --- a/src/framework/lib_common_mem/common_buf.c +++ b/src/framework/lib_common_mem/common_buf.c @@ -88,7 +88,8 @@ int log_level = LOG_INFO; int -nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode) +nscomm_pal_module_init (nsfw_mem_para * para, + common_mem_pal_module_info * pinfo, u8 app_mode) { char tempargv[PATA_NUM_MAX][PATA_STRLENT]; char *argv[PATA_NUM_MAX]; @@ -100,6 +101,12 @@ nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode) int retVal; char name[10] = { '\0' }; + if (para == NULL) + { + NSCOMM_LOGERR ("para is null"); + return DMM_MBUF_RET_ERR; + } + retVal = MEMSET_S (tempargv, sizeof (tempargv), '\0', sizeof (tempargv)); if (EOK != retVal) { @@ -112,8 +119,21 @@ nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode) NSCOMM_LOGERR ("MEMSET_S failed]ret=%d", retVal); return DMM_MBUF_RET_ERR; } - if (NULL == pinfo) + if (NSFW_PROC_MAIN == para->enflag) { + if (para->iargsnum != 0) + { + if (common_mem_pal_init (para->iargsnum, para->pargs) < 0) + { + COMMON_LOG_PRINT (LOG_ERR, "Cannot init pal\r\n"); + return DMM_MBUF_RET_ERR; + } + else + { + return DMM_MBUF_RET_OK; + } + } + PARA1_SET (argv, tempargv, agindex, "nStackMain"); PARA2_SET (argv, tempargv, agindex, "-c", "0x1"); PARA2_SET (argv, tempargv, agindex, "-n", "4"); diff --git a/stacks/lwip_stack/release/script/nstack_fun.sh b/stacks/lwip_stack/release/script/nstack_fun.sh index bb33a6a..5e16283 100644..100755 --- a/stacks/lwip_stack/release/script/nstack_fun.sh +++ b/stacks/lwip_stack/release/script/nstack_fun.sh @@ -332,10 +332,10 @@ run_nStackMain() log $LINENO "$env DPDK_TOOL_DIR=$DPDK_TOOL_DIR" log $LINENO "$env LD_LIBRARY_PATH=$LD_LIBRARY_PATH" log $LINENO "$env DPDK_LIB_PATH=$DPDK_LIB_PATH" - log $LINENO "./bin/nStackMain -c $1 -n 4 --huge-dir=$2 -m $3 stack -c $4 -sleep $5 -bind_cpu $6" + log $LINENO "./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 stack -c $4 -sleep $5 -bind_cpu $6" check_file_size $DPDK_FILE cd ..; cd bin/ - ./nStackMain -c $1 -n 4 --huge-dir=$2 -m $3 stack -c $4 -sleep $5 -bind_cpu $6 >> $DPDK_FILE & + ./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 stack -c $4 -sleep $5 -bind_cpu $6 >> $DPDK_FILE & } diff --git a/stacks/lwip_stack/release/script/nstack_var.sh b/stacks/lwip_stack/release/script/nstack_var.sh index 45efafc..9a1c612 100644 --- a/stacks/lwip_stack/release/script/nstack_var.sh +++ b/stacks/lwip_stack/release/script/nstack_var.sh @@ -52,7 +52,7 @@ HUGE_PAGES=2048 HUGE_DIR=/mnt/nstackhuge SLEEP_INTERVAL=100 # tcpip thread sleep time, unit: us BIND_CPU=0 -MEM_SIZE=2048 +MEM_SIZE=3072 RTP_CORE_MASK=2 MASTER_EXEC_PATH="/product/gpaas/nStackMaster/bin" diff --git a/stacks/lwip_stack/src/io_adpt/dpdk.c b/stacks/lwip_stack/src/io_adpt/dpdk.c index da2cfb6..d199513 100644 --- a/stacks/lwip_stack/src/io_adpt/dpdk.c +++ b/stacks/lwip_stack/src/io_adpt/dpdk.c @@ -191,6 +191,82 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = { }; /***************************************************************************** +* Prototype : dpdk_mbuf_to_file +* Description : write the packet data into a file +* Input : uint16_t pkt_number +* struct rte_mbuf **pkts +* Output : None +* Return Value : +* Calls : +* Called By : +* +*****************************************************************************/ +NSTACK_STATIC void +dpdk_mbuf_to_file (uint16_t pkt_number, struct rte_mbuf **pkts) +{ + char line[100] = { 0 }; + FILE *f = NULL; + struct rte_mbuf *p = NULL; + uint16_t len = 0, offset, i; + uint16_t pktlen = 0; + uint16_t start = 0; + uint16_t number = 0; + unsigned char *data = NULL; + + f = fopen ("/var/log/nStack/packet.txt", "a+"); + if (f == NULL) + { + NSHAL_LOGERR ("can not open the file:%s", "packet.txt"); + return; + } + + for (i = 0; i < pkt_number; i++) + { + pktlen = 0; + p = pkts[i]; + while (p) + { + len = 0; + data = rte_pktmbuf_mtod (p, unsigned char *); + while (len < p->data_len) + { + start = pktlen % 16; /* start of the line */ + if (start == 0) + { + number = SNPRINTF_S (line, sizeof (line), sizeof (line) - 1, + "%08X", len); + } + + for (offset = 0; + ((offset + start) < 16) && ((len + offset) < p->data_len); + offset++) + { + number += + SNPRINTF_S (line + number, sizeof (line), + sizeof (line) - 1, " %02X", + data[len + offset]); + } + + fprintf (f, "%s", line); + if ((offset + start) == 16) + fprintf (f, "\n"); + + len += offset; + pktlen += offset; + (void) MEMSET_S (line, sizeof (line), 0, sizeof (line)); + } + + p = p->next; + + } + fprintf (f, "\n"); + } + + fclose (f); + return; +} + +/***************************************************************************** * Prototype : hal_rte_eth_rx_burst * Description : a copy of rte_eth_rx_burst, because this function invokes a global(rte_eth_devices), which cannt be access by dlsym @@ -207,13 +283,13 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = { *****************************************************************************/ NSTACK_STATIC inline uint16_t hal_rte_eth_rx_burst (uint8_t port_id, uint16_t queue_id, - struct rte_mbuf **rx_pkts, const uint16_t nb_pkts) + struct rte_mbuf ** rx_pkts, const uint16_t nb_pkts) { #ifdef RTE_ETHDEV_RXTX_CALLBACKS struct rte_eth_rxtx_callback *cb; #endif int16_t nb_rx; - + char *pst_capture_packet = NULL; struct rte_eth_dev *dev = &rte_eth_devices[port_id]; if (NULL == dev->rx_pkt_burst) @@ -250,6 +326,11 @@ hal_rte_eth_rx_burst (uint8_t port_id, uint16_t queue_id, } #endif + //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET"); + if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0) + { + dpdk_mbuf_to_file (nb_rx, rx_pkts); + } return (uint16_t) nb_rx; } @@ -274,7 +355,8 @@ hal_rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id, #ifdef RTE_ETHDEV_RXTX_CALLBACKS struct rte_eth_rxtx_callback *cb; #endif - + int16_t nb_tx = 0; + char *pst_capture_packet = NULL; struct rte_eth_dev *dev = &rte_eth_devices[port_id]; if (NULL == dev->tx_pkt_burst) @@ -309,8 +391,16 @@ hal_rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id, } #endif - return (*dev->tx_pkt_burst) (dev->data->tx_queues[queue_id], tx_pkts, - nb_pkts); + nb_tx = (*dev->tx_pkt_burst) (dev->data->tx_queues[queue_id], tx_pkts, + nb_pkts); + + //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET"); + if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0) + { + dpdk_mbuf_to_file (nb_tx, tx_pkts); + } + + return nb_tx; } /***************************************************************************** |