aboutsummaryrefslogtreecommitdiffstats
path: root/package/network/utils
diff options
context:
space:
mode:
authorYangbo Lu <yangbo.lu@nxp.com>2017-10-18 10:37:58 +0800
committerJohn Crispin <john@phrozen.org>2017-11-10 23:00:47 +0100
commit23c1504059e187a279296bc827878c8dc314cc05 (patch)
treef1c71d63bc0ee8802de9931d189c35148dbb6567 /package/network/utils
parent1e0276a39af1094cff925148cc8340fc1893056d (diff)
downloadupstream-23c1504059e187a279296bc827878c8dc314cc05.tar.gz
upstream-23c1504059e187a279296bc827878c8dc314cc05.tar.bz2
upstream-23c1504059e187a279296bc827878c8dc314cc05.zip
layerscape: add restool package
restool is a user space application providing the ability to dynamically create and manage Layerscape DPAA2 containers and objects from Linux. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Diffstat (limited to 'package/network/utils')
-rw-r--r--package/network/utils/layerscape/restool/Makefile38
-rw-r--r--package/network/utils/layerscape/restool/patches/0001-scripts-move-shebang-on-the-first-line.patch35
-rw-r--r--package/network/utils/layerscape/restool/patches/0002-dprc-add-full-path-option-to-dprc-list-command.patch151
-rw-r--r--package/network/utils/layerscape/restool/patches/0003-scripts-remove-unnecessary-arrays.patch62
-rw-r--r--package/network/utils/layerscape/restool/patches/0004-scripts-use-restool-full-path-option.patch111
-rw-r--r--package/network/utils/layerscape/restool/patches/0005-scripts-use-proper-arithmetic-operation-syntax.patch26
-rw-r--r--package/network/utils/layerscape/restool/patches/0006-scripts-use-strings-instead-of-arrays.patch79
-rw-r--r--package/network/utils/layerscape/restool/patches/0007-scripts-use-Bourne-shell-s-pattern-matching.patch126
-rw-r--r--package/network/utils/layerscape/restool/patches/0008-scripts-use-Bourne-shell-instead-of-bash.patch32
-rw-r--r--package/network/utils/layerscape/restool/patches/0009-scripts-workaround-for-a-improper-sed-substitution-T.patch36
-rw-r--r--package/network/utils/layerscape/restool/patches/0010-scripts-use-proper-arithmetic-operations.patch44
-rw-r--r--package/network/utils/layerscape/restool/patches/0011-scripts-do-not-compare-strings-with-regexp-expressio.patch27
-rw-r--r--package/network/utils/layerscape/restool/patches/0012-scripts-replace-nproc-with-cross-platform-implementa.patch27
13 files changed, 794 insertions, 0 deletions
diff --git a/package/network/utils/layerscape/restool/Makefile b/package/network/utils/layerscape/restool/Makefile
new file mode 100644
index 0000000000..9340861152
--- /dev/null
+++ b/package/network/utils/layerscape/restool/Makefile
@@ -0,0 +1,38 @@
+#
+# Copyright 2017 NXP
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=restool
+PKG_VERSION:=2017.09
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/qoriq-open-source/restool.git
+PKG_SOURCE_VERSION:=8f08b9d499e84f9057784c2036f0ddf75ae3fc70
+PKG_MIRROR_HASH:=ff672b420041deac190cc9ddf314c52ec325567c429bc0aca3c692b2c7dc818f
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/restool
+ SECTION:=net
+ CATEGORY:=Network
+ DEPENDS:=@TARGET_layerscape
+ TITLE:=Layerscape DPAA2 dynamical management tool
+endef
+
+MAKE_FLAGS += \
+ DESTDIR="$(PKG_BUILD_DIR)"/output/ \
+ install
+
+define Package/restool/install
+ $(INSTALL_DIR) $(1)/usr/bin/
+ $(CP) $(PKG_BUILD_DIR)/output/usr/local/bin/* $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,restool))
diff --git a/package/network/utils/layerscape/restool/patches/0001-scripts-move-shebang-on-the-first-line.patch b/package/network/utils/layerscape/restool/patches/0001-scripts-move-shebang-on-the-first-line.patch
new file mode 100644
index 0000000000..691e3bba51
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0001-scripts-move-shebang-on-the-first-line.patch
@@ -0,0 +1,35 @@
+From 978f00c0a9f17de9cf17b205a741222084261d3a Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:29:17 +0000
+Subject: [PATCH 01/12] scripts: move shebang on the first line
+
+If the shebang is not placed on the first line of the shell script
+it will be accounted only as a comment.
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index 588c736..09bef5a 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -1,3 +1,5 @@
++#!/bin/bash
++
+ # Copyright 2013-2016 Freescale Semiconductor Inc.
+ # Copyright 2017 NXP
+
+@@ -30,8 +32,6 @@
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ # POSSIBILITY OF SUCH DAMAGE.
+
+-#!/bin/bash
+-
+ ## Restool wrapper script
+ #
+ # Prerequisites:
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0002-dprc-add-full-path-option-to-dprc-list-command.patch b/package/network/utils/layerscape/restool/patches/0002-dprc-add-full-path-option-to-dprc-list-command.patch
new file mode 100644
index 0000000000..0e39ef7245
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0002-dprc-add-full-path-option-to-dprc-list-command.patch
@@ -0,0 +1,151 @@
+From 6039bd1b7e5e71a0a171406cf980d2d61a6e79d4 Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:29:37 +0000
+Subject: [PATCH 02/12] dprc: add --full-path option to dprc list command
+
+Instead of printing an indented dprc list, activating
+the --full-path option restool will print the entire path
+of the dprc.
+Example:
+
+root@rodos:~# restool dprc list --full-path
+dprc.1
+dprc.1/dprc.3
+dprc.1/dprc.2
+dprc.1/dprc.2/dprc.4
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ dprc_commands.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++-----------
+ 1 file changed, 50 insertions(+), 11 deletions(-)
+
+diff --git a/dprc_commands.c b/dprc_commands.c
+index e1a8f16..8de2f0e 100644
+--- a/dprc_commands.c
++++ b/dprc_commands.c
+@@ -76,13 +76,16 @@ C_ASSERT(ARRAY_SIZE(dprc_sync_options) <= MAX_NUM_CMD_LINE_OPTIONS + 1);
+ */
+ enum dprc_list_options {
+ LIST_OPT_HELP = 0,
++ LIST_OPT_FULL_PATH,
+ };
+
+ static struct option dprc_list_options[] = {
+ [LIST_OPT_HELP] = {
+ .name = "help",
+ },
+-
++ [LIST_OPT_FULL_PATH] = {
++ .name = "full-path",
++ },
+ { 0 },
+ };
+
+@@ -421,17 +424,33 @@ static int cmd_dprc_sync(void)
+ * Lists nested DPRCs inside a given DPRC, recursively
+ */
+ static int list_dprc(uint32_t dprc_id, uint16_t dprc_handle,
+- int nesting_level, bool show_non_dprc_objects)
++ int nesting_level, bool show_non_dprc_objects,
++ char *full_path)
+ {
++ char *updated_full_path = NULL;
+ int num_child_devices;
+ int error = 0;
++ int full_path_len;
+
+ assert(nesting_level <= MAX_DPRC_NESTING);
+
+- for (int i = 0; i < nesting_level; i++)
+- printf(" ");
+-
+- printf("dprc.%u\n", dprc_id);
++ if (full_path) {
++ full_path_len = strlen(full_path);
++ updated_full_path = malloc(full_path_len + 10);
++ if (!updated_full_path) {
++ ERROR_PRINTF("Could not alloc memory for full-path!\n");
++ return -ENOMEM;
++ }
++ if (full_path_len != 0)
++ sprintf(updated_full_path, "%s/dprc.%d", full_path, dprc_id);
++ else
++ sprintf(updated_full_path, "dprc.%d", dprc_id);
++ printf("%s\n", updated_full_path);
++ } else {
++ for (int i = 0; i < nesting_level; i++)
++ printf(" ");
++ printf("dprc.%u\n", dprc_id);
++ }
+
+ error = dprc_get_obj_count(&restool.mc_io, 0,
+ dprc_handle,
+@@ -475,8 +494,11 @@ static int list_dprc(uint32_t dprc_id, uint16_t dprc_handle,
+ if (error < 0)
+ goto out;
+
+- error = list_dprc(obj_desc.id, child_dprc_handle,
+- nesting_level + 1, show_non_dprc_objects);
++ error = list_dprc(obj_desc.id,
++ child_dprc_handle,
++ nesting_level + 1,
++ show_non_dprc_objects,
++ updated_full_path);
+
+ error2 = dprc_close(&restool.mc_io, 0, child_dprc_handle);
+ if (error2 < 0) {
+@@ -491,6 +513,9 @@ static int list_dprc(uint32_t dprc_id, uint16_t dprc_handle,
+ }
+
+ out:
++ if (full_path)
++ free(updated_full_path);
++
+ return error;
+ }
+
+@@ -498,8 +523,14 @@ static int cmd_dprc_list(void)
+ {
+ static const char usage_msg[] =
+ "\n"
+- "Usage: restool dprc list\n"
++ "Usage: restool dprc list [OPTIONS]\n"
++ "\n"
++ "OPTIONS:\n"
++ "--full-path\n"
++ " prints the dprc list in a full-path\n"
++ " format like: dprc.1/dprc.2\n"
+ "\n";
++ bool full_path = false;
+
+ if (restool.cmd_option_mask & ONE_BIT_MASK(LIST_OPT_HELP)) {
+ puts(usage_msg);
+@@ -507,6 +538,12 @@ static int cmd_dprc_list(void)
+ return 0;
+ }
+
++
++ if (restool.cmd_option_mask & ONE_BIT_MASK(LIST_OPT_FULL_PATH)) {
++ restool.cmd_option_mask &= ~ONE_BIT_MASK(LIST_OPT_FULL_PATH);
++ full_path = true;
++ }
++
+ if (restool.obj_name != NULL) {
+ ERROR_PRINTF(
+ "Unexpected argument: \'%s\'\n\n", restool.obj_name);
+@@ -514,8 +551,10 @@ static int cmd_dprc_list(void)
+ return -EINVAL;
+ }
+
+- return list_dprc(
+- restool.root_dprc_id, restool.root_dprc_handle, 0, false);
++ return list_dprc(restool.root_dprc_id,
++ restool.root_dprc_handle,
++ 0, false,
++ full_path ? "" : NULL);
+ }
+
+ static int show_one_resource_type(uint16_t dprc_handle,
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0003-scripts-remove-unnecessary-arrays.patch b/package/network/utils/layerscape/restool/patches/0003-scripts-remove-unnecessary-arrays.patch
new file mode 100644
index 0000000000..c846fbab5b
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0003-scripts-remove-unnecessary-arrays.patch
@@ -0,0 +1,62 @@
+From e316b4c7d421afa6ca5f6b6ae86d0a8219a9bd56 Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:29:42 +0000
+Subject: [PATCH 03/12] scripts: remove unnecessary arrays
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 22 ++--------------------
+ 1 file changed, 2 insertions(+), 20 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index 09bef5a..ea0df92 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -87,8 +87,6 @@ root_c=
+ # Type of endpoint object
+ toe=
+
+-dpnis=()
+-dpmacs=()
+ containers=()
+ # Full path containers
+ fpc=()
+@@ -944,16 +942,8 @@ process_listni() {
+ fi
+ fi
+
+- dpnis+=("$dpni $details")
++ echo "${i}/${dpni} ${details}"
+ done
+-
+- if [ -n "$dpnis" ]; then
+- for j in "${dpnis[@]}"; do
+- echo "$i/$j"
+- done
+-
+- dpnis=()
+- fi
+ done
+ }
+
+@@ -984,16 +974,8 @@ process_listmac() {
+ fi
+ fi
+
+- dpmacs+=("$dpmac $details")
++ echo "${i}/${dpmac} ${details}"
+ done
+-
+- if [ -n "$dpmacs" ]; then
+- for j in "${dpmacs[@]}"; do
+- echo "$i/$j"
+- done
+-
+- dpmacs=()
+- fi
+ done
+ }
+
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0004-scripts-use-restool-full-path-option.patch b/package/network/utils/layerscape/restool/patches/0004-scripts-use-restool-full-path-option.patch
new file mode 100644
index 0000000000..e1cc38f481
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0004-scripts-use-restool-full-path-option.patch
@@ -0,0 +1,111 @@
+From 09f840049d155fa4b681ece749feeff9a269ecde Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:29:45 +0000
+Subject: [PATCH 04/12] scripts: use restool --full-path option
+
+Instead of constructing the the full path container list by
+hand use the restool option newly added.
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 54 +++++++-----------------------------------------------
+ 1 file changed, 7 insertions(+), 47 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index ea0df92..72f6c77 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -73,7 +73,6 @@
+ ##
+
+ shopt -s extglob
+-shopt -s lastpipe
+
+ # Intercept the Ctrl+C command but do not interrupt execution
+ trap ' ' INT
+@@ -87,11 +86,6 @@ root_c=
+ # Type of endpoint object
+ toe=
+
+-containers=()
+-# Full path containers
+-fpc=()
+-idx=0
+-
+ SYS_DPRC="/sys/bus/fsl-mc/drivers/fsl_mc_dprc"
+
+ set -e
+@@ -220,42 +214,6 @@ get_container() {
+ echo $(echo "$i" | sed "s/\(dprc.[0-9]*\/\)*//g")
+ }
+
+-build_fpc_list() {
+- $restool dprc list |
+- while IFS= read -r line
+- do
+- containers+=("$line")
+- done
+-
+- for i in "${containers[@]}"
+- do
+- cnt=$(count_spaces "$i")
+-
+- if [ "$cnt" -gt 0 ]; then
+- # Get index of the upper level container
+- idx2=$((idx-1))
+- crt_ct="$i"
+-
+- while [ "$idx2" -ge 0 ]
+- do
+- cntp=$(count_spaces "${containers[idx2]}")
+-
+- if [ "$cntp" -lt "$cnt" ]; then
+- upc=$(echo "${containers[idx2]}" | sed "s/ *$//")
+- crt_ct=$upc"/""$(echo $crt_ct | sed 's/ *$//')"
+- fi
+- idx2=$((idx2-1))
+- done
+-
+- fpc+=($crt_ct)
+- else
+- fpc+=("$i")
+- fi
+-
+- idx=$((idx+1))
+- done
+-}
+-
+ get_label() {
+ # Retrieve the type of the object
+ too=$(echo "$1" | sed "s/\(\.[0-9]*\)\(\.[0-9]*\)*$//g")
+@@ -897,9 +855,9 @@ process_addni() {
+ }
+
+ process_listni() {
+- build_fpc_list
+-
+- for i in "${fpc[@]}"
++ dprc_list="$($restool dprc list --full-path)"
++ echo "${dprc_list}" |
++ while read -r i
+ do
+ crt_c=$(get_container "$i")
+ $restool dprc show "$crt_c" | grep dpni |
+@@ -948,10 +906,12 @@ process_listni() {
+ }
+
+ process_listmac() {
+- build_fpc_list
++ dprc_list="$($restool dprc list --full-path)"
+
+- for i in "${fpc[@]}"
++ echo "${dprc_list}" |
++ while read -r i
+ do
++
+ crt_c=$(get_container "$i")
+ $restool dprc show "$crt_c" | grep dpmac |
+ while IFS= read -r line
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0005-scripts-use-proper-arithmetic-operation-syntax.patch b/package/network/utils/layerscape/restool/patches/0005-scripts-use-proper-arithmetic-operation-syntax.patch
new file mode 100644
index 0000000000..b34c6a31ad
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0005-scripts-use-proper-arithmetic-operation-syntax.patch
@@ -0,0 +1,26 @@
+From 899d6c74286cbc672e1bad1abd7eff15b1b7298d Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:29:49 +0000
+Subject: [PATCH 05/12] scripts: use proper arithmetic operation syntax
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index 72f6c77..a39df2c 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -966,7 +966,7 @@ fi
+
+ # Check compatibility with MC version
+ mc_major=$($restool --mc-version | cut -f2 -d':' | cut -f1 -d'.' | tr -d ' ')
+-if (( $mc_major != 10 )); then
++if [ $mc_major != 10 ]; then
+ echo "Restool wrapper scripts only support the latest major MC version\n"
+ echo "that currently is MC10.x. Use with caution."
+ fi
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0006-scripts-use-strings-instead-of-arrays.patch b/package/network/utils/layerscape/restool/patches/0006-scripts-use-strings-instead-of-arrays.patch
new file mode 100644
index 0000000000..a1217668f5
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0006-scripts-use-strings-instead-of-arrays.patch
@@ -0,0 +1,79 @@
+From 2127850302de2bd8dccff0e31415ce0218750773 Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:29:53 +0000
+Subject: [PATCH 06/12] scripts: use strings instead of arrays
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 21 ++++++++++++++-------
+ 1 file changed, 14 insertions(+), 7 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index a39df2c..b0c742e 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -485,7 +485,9 @@ create_dpsw() {
+
+ # Make a link in case there is an end point specified
+ index=0
+- for i in "${endpoint[@]}"; do
++ echo "${endpoint}" |
++ while read -r i
++ do
+ connect $root_c "$dpsw.$index" "$i"
+ index=$((index + 1))
+ done
+@@ -519,8 +521,8 @@ process_addsw() {
+ max_fdb_mc_groups=32
+ # dpsw object label
+ label=
+- #Endpoint objects provided as argument
+- endpoint=()
++ # Endpoint objects provided as argument
++ endpoint=
+ ifcnt=0
+ container=$root_c
+
+@@ -559,7 +561,7 @@ process_addsw() {
+ container="${i#*=}"
+ ;;
+ @(dpni|dpmac).+([0-9]))
+- endpoint[$ifcnt]="$(echo ${i#*=} | tr -d ,)"
++ endpoint="${endpoint}"$'\n'"${i}"
+ ifcnt=$((ifcnt + 1))
+ ;;
+ *)
+@@ -571,14 +573,19 @@ process_addsw() {
+ done
+
+ # Check if there are more endpoints provided than the number of the interfaces
+- if [ $num_ifs -lt ${#endpoint[@]} ]; then
++ if [ $num_ifs -lt $ifcnt ]; then
+ echo "Error: there are more endpoints provided than the number of the interfaces"
+ usage_addsw
+ exit 1
+ fi
+
++ # Delete first empty line from the endpoint string
++ endpoint="$(echo "${endpoint}" | tail -n +2)"
++
+ # Check if the endpoints are valid
+- for i in "${endpoint[@]}"; do
++ echo "${endpoint}" |
++ while read -r i
++ do
+ type_of_endpoint "$i"
+ check_endpoint "$i"
+ has_endpoint "$i"
+@@ -592,7 +599,7 @@ process_addsw() {
+ if (( $object_exists_status == 1 )); then
+ echo "Created ETHSW object $dpsw with ${num_ifs} ports"
+
+- if [ $num_ifs -gt ${#endpoint[@]} ]; then
++ if [ $num_ifs -gt $ifcnt ]; then
+ echo "Do not forget to connect devices to interface(s)."
+ fi
+ fi
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0007-scripts-use-Bourne-shell-s-pattern-matching.patch b/package/network/utils/layerscape/restool/patches/0007-scripts-use-Bourne-shell-s-pattern-matching.patch
new file mode 100644
index 0000000000..ed9d76d454
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0007-scripts-use-Bourne-shell-s-pattern-matching.patch
@@ -0,0 +1,126 @@
+From e1036011baf9204d5fe6dd74e5a65f95b9681ebd Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:29:56 +0000
+Subject: [PATCH 07/12] scripts: use Bourne shell's pattern matching
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 71 ++++++++++++++++++++++++++++-----------------------------
+ 1 file changed, 35 insertions(+), 36 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index b0c742e..a8b9573 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -72,8 +72,6 @@
+ #
+ ##
+
+-shopt -s extglob
+-
+ # Intercept the Ctrl+C command but do not interrupt execution
+ trap ' ' INT
+
+@@ -370,15 +368,16 @@ process_addmux() {
+ -c=* | --container=*)
+ container="${i#*=}"
+ ;;
+- *(dprc.+([0-9])/)dpmac.+([0-9]))
+- endpoint="${i#*=}"
+- ;;
+- *(dprc.+([0-9])/)dpni.+([0-9]))
+- endpoint="${i#*=}"
+- ;;
+ *)
+- usage_addmux
+- exit 1
++ arg_dpmac="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpmac.[0-9]+" || true )"
++ arg_dpni="$(echo $i | grep -x -E "(dprc.+[0-9]+/)*dpni.[0-9]+" || true )"
++ if [ "$i" = "$arg_dpmac" ] ||
++ [ "$i" = "$arg_dpni" ]; then
++ endpoint="$i"
++ else
++ usage_addmux
++ exit 1
++ fi
+ ;;
+ esac
+ done
+@@ -560,14 +559,17 @@ process_addsw() {
+ -c=* | --container=*)
+ container="${i#*=}"
+ ;;
+- @(dpni|dpmac).+([0-9]))
+- endpoint="${endpoint}"$'\n'"${i}"
+- ifcnt=$((ifcnt + 1))
+- ;;
+ *)
+- echo "Error: $i argument is invalid"
+- usage_addsw
+- exit 1
++ arg_dpmac="$(echo $i | grep -x -E "dpmac.[0-9]+" || true )"
++ arg_dpni="$(echo $i | grep -x -E "dpni.[0-9]+" || true )"
++ if [ "$i" = "$arg_dpmac" ] ||
++ [ "$i" = "$arg_dpni" ]; then
++ endpoint="$i"
++ else
++ echo "Error: $i argument is invalid"
++ usage_addsw
++ exit 1
++ fi
+ ;;
+ esac
+ done
+@@ -704,7 +706,8 @@ process_addni() {
+ ;;
+ --mac-addr=*)
+ mac_addr="${i#*=}"
+- if [[ ! "$mac_addr" =~ ^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$ ]]; then
++ mac_addr_valid="$(echo $mac_addr | grep -x -E "^([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}$" || true )"
++ if [ "$mac_addr" != "$mac_addr_valid" ]; then
+ echo "Invalid MAC address: $mac_addr"
+ exit 1
+ fi
+@@ -776,25 +779,21 @@ process_addni() {
+ -o=* | --options=*)
+ options="${i#*=}"
+ ;;
+- *(dprc.+([0-9])/)dpmac.+([0-9]))
+- no_link=0
+- endpoint="${i#*=}"
+- ;;
+- *(dprc.+([0-9])/)dpni.+([0-9]))
+- no_link=0
+- endpoint="${i#*=}"
+- ;;
+- *(dprc.+([0-9])/)dpdmux.+([0-9]).+([0-9]))
+- no_link=0
+- endpoint="${i#*=}"
+- ;;
+- *(dprc.+([0-9])/)dpsw.+([0-9]).+([0-9]))
+- no_link=0
+- endpoint="${i#*=}"
+- ;;
+ *)
+- usage_addni
+- exit 1
++ arg_dpmac="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpmac.[0-9]+" || true )"
++ arg_dpni="$(echo $i | grep -x -E "(dprc.+[0-9]+/)*dpni.[0-9]+" || true )"
++ arg_dpdmux="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpdmux.[0-9]+.[0-9]+" || true )"
++ arg_dpsw="$(echo $i | grep -x -E "(dprc.[0-9]+/)*dpsw.[0-9]+.[0-9]+" || true )"
++ if [ "$i" = "$arg_dpmac" ] ||
++ [ "$i" = "$arg_dpni" ] ||
++ [ "$i" = "$arg_dpdmux" ] ||
++ [ "$i" = "$arg_dpsw" ]; then
++ no_link=0
++ endpoint="$i"
++ else
++ usage_addni
++ exit 1
++ fi
+ ;;
+ esac
+ done
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0008-scripts-use-Bourne-shell-instead-of-bash.patch b/package/network/utils/layerscape/restool/patches/0008-scripts-use-Bourne-shell-instead-of-bash.patch
new file mode 100644
index 0000000000..4921f63c9e
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0008-scripts-use-Bourne-shell-instead-of-bash.patch
@@ -0,0 +1,32 @@
+From 4a1df345edc59a7407b955529955d6799d974b70 Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Tue, 24 Oct 2017 16:30:00 +0000
+Subject: [PATCH 08/12] scripts: use Bourne shell instead of bash
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index a8b9573..bd79295 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/bin/sh
+
+ # Copyright 2013-2016 Freescale Semiconductor Inc.
+ # Copyright 2017 NXP
+@@ -37,7 +37,7 @@
+ # Prerequisites:
+ # - Management Complex version 10.x
+ # - restool version 1.4 or newer
+-# - bash shell
++# - Bourne Shell (sh)
+ #
+ #
+ # The purpose of this script is to offer a user friendly way to create
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0009-scripts-workaround-for-a-improper-sed-substitution-T.patch b/package/network/utils/layerscape/restool/patches/0009-scripts-workaround-for-a-improper-sed-substitution-T.patch
new file mode 100644
index 0000000000..c642afcafa
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0009-scripts-workaround-for-a-improper-sed-substitution-T.patch
@@ -0,0 +1,36 @@
+From ac387de9688099bca1fbdb587d078b369aaf2dab Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Wed, 25 Oct 2017 11:23:42 +0000
+Subject: [PATCH 09/12] scripts: workaround for a improper sed substitution
+ (TODO)
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index bd79295..7ce73f0 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -197,7 +197,7 @@ has_endpoint() {
+ ep=$($restool "$toe" info "$1" | grep "endpoint:" | sed "s/endpoint: \([^ ]*\)\,.*/\1/")
+ fi
+
+- if [[ "$ep" != *"No object associated"* && "$ep" != *"none"* ]]; then
++ if [[ "$ep" != "endpoint: No object associated" && "$ep" != *"none"* ]]; then
+ echo "$1 is already linked to $ep"
+ exit 1
+ fi
+@@ -230,7 +230,7 @@ get_endpoint() {
+ end_point=$($restool "$too" info "$1" | grep "endpoint:" | sed "s/endpoint: \([^ ]*\)\,.*/\1/")
+ fi
+
+- if [[ "$end_point" != *"No object associated"* && "$end_point" != *"none"* ]]; then
++ if [[ "$end_point" != "endpoint: No object associated" && "$end_point" != *"none"* ]]; then
+ echo "$end_point"
+ fi
+ }
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0010-scripts-use-proper-arithmetic-operations.patch b/package/network/utils/layerscape/restool/patches/0010-scripts-use-proper-arithmetic-operations.patch
new file mode 100644
index 0000000000..9945cd438a
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0010-scripts-use-proper-arithmetic-operations.patch
@@ -0,0 +1,44 @@
+From 66ae6e5313da8be5742a502c0d7027689e84a17d Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Wed, 25 Oct 2017 11:30:08 +0000
+Subject: [PATCH 10/12] scripts: use proper arithmetic operations
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index 7ce73f0..0dcd2fa 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -409,7 +409,7 @@ process_addmux() {
+
+ # check the status
+ object_exists $container $dpdmux
+- if (( $object_exists_status == 1 )); then
++ if [ $object_exists_status == 1 ]; then
+
+ if [ "$root_c" == "$container" ]; then
+ evb=$(ls $SYS_DPRC/"$root_c"/"$dpdmux"/net/ | grep -v "p")
+@@ -598,7 +598,7 @@ process_addsw() {
+
+ # check the status
+ object_exists $container $dpsw
+- if (( $object_exists_status == 1 )); then
++ if [ $object_exists_status == 1 ]; then
+ echo "Created ETHSW object $dpsw with ${num_ifs} ports"
+
+ if [ $num_ifs -gt $ifcnt ]; then
+@@ -850,7 +850,7 @@ process_addni() {
+
+ # check the status
+ object_exists $container $dpni
+- if (( $object_exists_status == 1 )); then
++ if [ $object_exists_status == 1 ]; then
+ if [ "$root_c" == "$container" ]; then
+ ni=$(ls $SYS_DPRC/"$root_c"/"$dpni"/net/)
+ fi
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0011-scripts-do-not-compare-strings-with-regexp-expressio.patch b/package/network/utils/layerscape/restool/patches/0011-scripts-do-not-compare-strings-with-regexp-expressio.patch
new file mode 100644
index 0000000000..1b6cc46a38
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0011-scripts-do-not-compare-strings-with-regexp-expressio.patch
@@ -0,0 +1,27 @@
+From 6af86a65f2dcfd42f572e04207eef45da3573b92 Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Wed, 25 Oct 2017 11:30:33 +0000
+Subject: [PATCH 11/12] scripts: do not compare strings with regexp expressions
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index 0dcd2fa..526c052 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -805,7 +805,8 @@ process_addni() {
+ fi
+
+ # if no --num-queues is specified then set it to number of cores
+- if [[ $dpni_args != *"--num-queues"* ]]; then
++ num_queues_present=$(echo "$dpni_args" | grep -o "\-\-num-queues" || true)
++ if [[ -z "$num_queues_present" ]]; then
+ dpni_args=$dpni_args" --num-queues="$(nproc)
+ fi
+
+--
+2.14.1
+
diff --git a/package/network/utils/layerscape/restool/patches/0012-scripts-replace-nproc-with-cross-platform-implementa.patch b/package/network/utils/layerscape/restool/patches/0012-scripts-replace-nproc-with-cross-platform-implementa.patch
new file mode 100644
index 0000000000..3acb3b5d83
--- /dev/null
+++ b/package/network/utils/layerscape/restool/patches/0012-scripts-replace-nproc-with-cross-platform-implementa.patch
@@ -0,0 +1,27 @@
+From 0e5f9f0a7f0ef1947984cd82ade9dbc14ba2c80d Mon Sep 17 00:00:00 2001
+From: Ioana Ciornei <ioana.ciornei@nxp.com>
+Date: Wed, 25 Oct 2017 12:48:04 +0000
+Subject: [PATCH 12/12] scripts: replace 'nproc' with cross-platform
+ implementation
+
+Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
+---
+ scripts/ls-main | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/scripts/ls-main b/scripts/ls-main
+index 526c052..7d127f6 100755
+--- a/scripts/ls-main
++++ b/scripts/ls-main
+@@ -807,7 +807,7 @@ process_addni() {
+ # if no --num-queues is specified then set it to number of cores
+ num_queues_present=$(echo "$dpni_args" | grep -o "\-\-num-queues" || true)
+ if [[ -z "$num_queues_present" ]]; then
+- dpni_args=$dpni_args" --num-queues="$(nproc)
++ dpni_args=$dpni_args" --num-queues="$(grep -c ^processor /proc/cpuinfo)
+ fi
+
+ # Check if --no-link the endpoint have been provided otherwise display the usage
+--
+2.14.1
+