[][MAC80211][hnat][Add nft hardware flow offload]

[Description]
Add nft hardware flow offload.

Users can follow the SOP below to activate the nft hardware flow offload.

1. Add nft offload rule
========================================================================
nft_hw_offload.conf
========================================================================
table ip filter {
	flowtable f {
		hook ingress priority filter + 1
		devices = { lan0, lan1, lan2, lan3, eth1 }
		counter;
		flags offload;
	}

	chain input {
		type filter hook input priority filter; policy accept;
	}

	chain output {
		type filter hook output priority filter; policy accept;
	}

	chain forward {
		type filter hook forward priority filter; policy accept;
		ip protocol { tcp, udp } flow add @f
	}
}
table ip nat {
	chain post {
		type nat hook postrouting priority filter; policy accept;
		oifname "eth1" masquerade
	}

	chain pre {
		type nat hook prerouting priority filter; policy accept;
	}
}
========================================================================

2. Apply nft offload rule
   nft -f ./nft_hw_offload.conf

3. List offload rule
   nft list flowtables

Without this patch, users are unable to activate hardware flow offload
with nftables.

[Release-log]
N/A


Change-Id: I4df063eab3253d90943742c5a0831ca0ea1a763d
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/10215694
3 files changed
tree: 56a22bd5935b736e613afab329186dc97257b015
  1. 21.02/
  2. 24.10/
  3. autobuild/
  4. feed/
  5. master/
  6. scripts/
  7. tools/
  8. .checkpatch.conf
  9. .clang-format
  10. .gitignore
  11. mtk-openwrt-feeds-commit-sha-mapping-table.md
  12. prepare_sdk.sh
  13. Readme.md
Readme.md

Brief introduction for using MediaTek released OpenWrt SDK

1. Build system setup

2. Clone vanilla OpenWrt

Currently two release branches are supported:

  1. 21.02 This is the current in-use branch

    git clone -b openwrt-21.02 https://git.openwrt.org/openwrt/openwrt.git
    
  2. master (will be 24.0x branch later) The next version in development

    git clone https://git.openwrt.org/openwrt/openwrt.git
    

3. Add MediaTek OpenWrt feed

cd openwrt
echo "src-git mtk_openwrt_feed https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds" >> feeds.conf.default
./scripts/feeds update -a
./scripts/feeds install -a

4. Apply MediaTek OpenWrt files and patches

  1. 21.02 branch

    cp -af ./feeds/mtk_openwrt_feed/21.02/files/* .
    cp -af ./feeds/mtk_openwrt_feed/tools .
    for file in $(find ./feeds/mtk_openwrt_feed/21.02/patches-base -name "*.patch" | sort); do patch -f -p1 -i ${file}; done
    for file in $(find ./feeds/mtk_openwrt_feed/21.02/patches-feeds -name "*.patch" | sort); do patch -f -p1 -i ${file}; done
    
  2. master branch

    cp -af ./feeds/mtk_openwrt_feed/master/files/* .
    for file in $(find ./feeds/mtk_openwrt_feed/master/patches-base -name "*.patch" | sort); do patch -f -p1 -i ${file}; done
    

5. Configuration

make menuconfig
  1. 21.02 branch

    Target System -> MediaTek Ralink ARM
    Subtarget -> MT7981 / MT7986 / MT7988
    Target Profile -> select as needed
    
  2. master branch

    Target System -> MediaTek Ralink ARM
    Subtarget -> Filogic 8x0 (MT798x)
    Target Profile -> select as needed
    

6. Build

make V=s -j$(nproc)

MT7987 NPU Only (without WiFi) Build

#Get Openwrt 21.02 source code from Git server
git clone --branch openwrt-21.02 https://git.openwrt.org/openwrt/openwrt.git

#Get Openwrt master source code from Git Server
git clone --branch master https://git.openwrt.org/openwrt/openwrt.git mac80211_package

#Get mtk-openwrt-feeds source code
git clone --branch master https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds

#Change to openwrt folder
cp -rf mtk-openwrt-feeds/autobuild/autobuild_5.4_mac80211_release openwrt
cd openwrt; mv autobuild_5.4_mac80211_release autobuild

#Add MTK feed
echo "src-git mtk_openwrt_feed https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds" >> feeds.conf.default

#Build MT7987 (Only for the 1st build)
bash autobuild/mt7987-npu/lede-branch-build-sanity.sh

#Further Build (After 1st full build)
./scripts/feeds update -a
make V=s PKG_HASH=skip PKG_MIRROR_HASH=skip