diff --git a/data/appendix/fast.tex b/data/appendix/fast.tex index 45d7641..954ca99 100644 --- a/data/appendix/fast.tex +++ b/data/appendix/fast.tex @@ -27,4 +27,810 @@ FAST软件的编程主要包括UA编程、规则管理编程和寄存器访问 UA编程主要处理硬件送到指定软件的分组数据; 规则管理编程主要是对硬件流表的读写管理; 寄存器访问控制编程主要是对硬件各寄存器资源的访问控制。 -对硬件规则的读写与对硬件其他寄存器的读写需要了解FAST架构的虚拟地址空间定义。 \ No newline at end of file +对硬件规则的读写与对硬件其他寄存器的读写需要了解FAST架构的虚拟地址空间定义。 + +\subsection{FAST软件获取} +\label{subsec:app:fast_get-soft} + +FAST的软硬件代码和相关工具下载请查看文章结尾的百度网盘链接。 + +\subsection{FAST代码结构} + +\subsubsection{目录结构} + +\renewcommand{\arraystretch}{1.5} +\begin{table}[!ht] + \small + \centering + \caption{以太网帧格式} + \label{tab:c:wireshark_eth-format} + \begin{tabular}{|c|c|c|} \hline + \heiti 序号 & \heiti 目录名称 & \heiti 说明\\ \hline + 1 & include & 开发所用头文件目录\\ \hline + 2 & lib & ua、寄存器读写库目录\\ \hline + 4 & app & fast应用工具\\ \hline + 6 & tools & 调试测试示例工具\\ \hline + 7 & src & 综合示例代码测试\\ \hline + \end{tabular} +\end{table} + +\subsubsection{头文件} + +\begin{enumerate} + \item Fast\_vaddr.h:FAST平台硬件资源访问对应的虚拟地址空间定义 + \item Fast\_type.h:FAST平台所用数据类型定义 + \item Fast\_err.h:FAST平台错误号定义 + \item Fast\_struct.h:FAST平台数据结构类型定义 + \item Fast.h:FAST平台所有开发函数定义,包含上述所有头文件 + \item 其他:不同平台的适配头文件 +\end{enumerate} + +\subsubsection{开发示例} + +开发示例提供了一个基于FAST架构的2层交换机实例, +综合使用了libreg和libua两个库实现了一个全软件的2层交换机功能。 + +\begin{enumerate} + \item L2switch + + L2switch是基于FAST架构开发一个2层以太网交换机原型, + 通过对流表默认规则的设置,将硬件所有的分组重定向到UA程序, + 然后在UA的分组处理回调函数中实现对分组的2层交换, + 然后将分组从指定端口发送或泛洪发送。 + 该示例主要演示了UA编程开发的主要方法与流程、使用的相关函数, + 硬件寄存器地址的操作,以及2层交换机的实现原理。 + +\item xofp + + xofp是基于FAST架构开发一个SDN交换机原型, + 通过OpenFlow协议连接SDN控制器,SDN交换机默认规则是送往SDN控制器, + SDN控制器根据报文数据,配置流表转发下发给硬件,下次进来的报文直接转发输出。 + 该示例主要演示了SDN交换机OpenFLow协议、处理OpenFLow消息、 + 使用的相关函数,硬件寄存器地址的操作,以及SDN交换机的实现原理。 +\end{enumerate} + +\subsubsection{工具} + +示例程序的另一种表现就是FAST提供的一些小工具,包括单独的寄存器读写命令、规则输出命令、端口状态显示命令和端口分组计数命令。 + +\begin{enumerate} + \item Reg\_rw + + 该工具主要是使用libreg库实现一个对用户指定的寄存器进行读写访问操作,展示了用户如何调用libreg的相关库函数进行寄存器访问操作的方法。 + \item Rule\_hw + + 该工具主要是使用libreg库和librule库实现对硬件流表的获取并分组输出操作,展示了用户如何调用librule库的相关库函数进行规则操作。该工具目前只使用了硬件规则的读取操作,更多规则的功能操作可参考综合测试程序 + \item Port\_status + + 该工具主要使用libreg库实现了对各端口的协商状态、链路状态等寄存器的访问并进行各状态值的解释。主要展示了不同端口状态的寄存器地址如何计算,各状态寄存器值返回如何解释,示例代码中包含了目前支持的所有状态寄存器及对应功能说明 + \item Port\_counts + + 该工具主要使用libreg库实现了对各端口分组计数的统计显示,主要展示了不同功能计数统计的寄存器虚拟地址空间定义,各端口对应功能寄存器的计算方法。示例代码中包含了目前支持的所有功能计数统计寄存器定义与说明 +\end{enumerate} + +\subsubsection{综合测试} + +综合测试程序包含了libreg、librule和libua库的综合开发示例功能。 +首先,用户可以通过此程序了解各功能库的主要使用函数及调用顺序; +其次,用户可以通过此程序的编译参数了解不同功能库如何添加对应库功能支持 + +subsection{FAST代码运行} + +\subsubsection{软硬件环境} +FAST平台由湖南新实网络科技有限公司提供销售、售后与技术支持。 +该平台可通过采购或免费申请试用获取,用户拿到FAST平台后, +默认系统环境均已支持FAST硬件基础版本与FAST软件基础版本。 +FAST硬件基础版本是指基于FAST的标准5组流水线功能; +FAST软件基础版本是指FAST-XXX软件版本。 + +如果用户只需要了解软件功能,可以不用FAST设备, +FAST软件可在通用Linux系统中进行编译与测试, +没有硬件平台的软件代码,不能进行硬件寄存器读写、规则配置与报文收发功能。 + +\subsubsection{代码获取} +参考第\ref{subsec:app:fast_get-soft}节 + +\subsubsection{代码编译} +\begin{enumerate} + \item 解压代码 + \begin{code}[console] + openbox@OpenBox~/hnxs$ tar –zxf fast-0.4.5.tar.gz + openbox@OpenBox~/hnxs$ cd fast-0.4.5 + openbox@OpenBox~/hnxs/fast-0.4.5$ ls + aclocal.m4 config.guess config.sub include ltmain.sh NEWS + app config.h configure INSTALL Makefile README + AUTHORS config.h.in configure.ac install-sh Makefile.am src + ChangeLog config.log COPYING lib Makefile.in stamp-h1 + compile config.status depcomp libtool missing tools + \end{code} + \item 配置环境 + \begin{code}[console] + openbox@OpenBox~/hnxs/fast-0.4.5$ ./configure + checking for a BSD-compatible install... /usr/bin/install -c + checking whether build environment is sane... yes + checking for a thread-safe mkdir -p... /bin/mkdir -p + checking for gawk... gawk + checking whether make sets $(MAKE)... yes + checking whether make supports nested variables... yes + checking whether make supports nested variables... (cached) yes + checking for gcc... gcc + checking whether the C compiler works... yes + checking for C compiler default output file name... a.out + checking for suffix of executables... + checking whether we are cross compiling... no + checking for suffix of object files... o + checking whether we are using the GNU C compiler... yes + checking whether gcc accepts -g... yes + checking for gcc option to accept ISO C89... none needed + checking whether gcc understands -c and -o together... yes + checking for style of include used by make... GNU + checking dependency style of gcc... gcc3 + checking whether NLS is requested... yes + checking for intltool >= 0.35.0... 0.50.2 found + checking for intltool-update... /usr/bin/intltool-update + checking for intltool-merge... /usr/bin/intltool-merge + checking for intltool-extract... /usr/bin/intltool-extract + checking for xgettext... /usr/bin/xgettext + checking for msgmerge... /usr/bin/msgmerge + checking for msgfmt... /usr/bin/msgfmt + checking for gmsgfmt... /usr/bin/msgfmt + checking for perl... /usr/bin/perl + checking for perl >= 5.8.1... 5.18.2 + checking for XML::Parser... ok + checking how to run the C preprocessor... gcc -E + checking for grep that handles long lines and -e... /bin/grep + checking for egrep... /bin/grep -E + checking for ANSI C header files... yes + checking for sys/types.h... yes + checking for sys/stat.h... yes + checking for stdlib.h... yes + checking for string.h... yes + checking for memory.h... yes + checking for strings.h... yes + checking for inttypes.h... yes + checking for stdint.h... yes + checking for unistd.h... yes + checking locale.h usability... yes + checking locale.h presence... yes + checking for locale.h... yes + checking for LC_MESSAGES... yes + checking libintl.h usability... yes + checking libintl.h presence... yes + checking for libintl.h... yes + checking for ngettext in libc... yes + checking for dgettext in libc... yes + checking for bind_textdomain_codeset... yes + checking for msgfmt... (cached) /usr/bin/msgfmt + checking for dcgettext... yes + checking if msgfmt accepts -c... yes + checking for gmsgfmt... (cached) /usr/bin/msgfmt + checking for xgettext... (cached) /usr/bin/xgettext + checking build system type... x86_64-unknown-linux-gnu + checking host system type... x86_64-unknown-linux-gnu + checking how to print strings... printf + checking for a sed that does not truncate output... /bin/sed + checking for fgrep... /bin/grep -F + checking for ld used by gcc... /usr/bin/ld + checking if the linker (/usr/bin/ld) is GNU ld... yes + checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B + checking the name lister (/usr/bin/nm -B) interface... BSD nm + checking whether ln -s works... yes + checking the maximum length of command line arguments... 1572864 + checking whether the shell understands some XSI constructs... yes + checking whether the shell understands "+="... yes + checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop + checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop + checking for /usr/bin/ld option to reload object files... -r + checking for objdump... objdump + checking how to recognize dependent libraries... pass_all + checking for dlltool... no + checking how to associate runtime and link libraries... printf %s\n + checking for ar... ar + checking for archiver @FILE support... @ + checking for strip... strip + checking for ranlib... ranlib + checking command to parse /usr/bin/nm -B output from gcc object... ok + checking for sysroot... no + checking for mt... mt + checking if mt is a manifest tool... no + checking for dlfcn.h... yes + checking for objdir... .libs + checking if gcc supports -fno-rtti -fno-exceptions... no + checking for gcc option to produce PIC... -fPIC -DPIC + checking if gcc PIC flag -fPIC -DPIC works... yes + checking if gcc static flag -static works... yes + checking if gcc supports -c -o file.o... yes + checking if gcc supports -c -o file.o... (cached) yes + checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes + checking whether -lc should be explicitly linked in... no + checking dynamic linker characteristics... GNU/Linux ld.so + checking how to hardcode library paths into programs... immediate + checking whether stripping libraries is possible... yes + checking if libtool supports shared libraries... yes + checking whether to build shared libraries... yes + checking whether to build static libraries... yes + checking that generated files are newer than configure... done + configure: creating ./config.status + config.status: creating Makefile + config.status: creating include/Makefile + config.status: creating libreg/Makefile + config.status: creating libua/Makefile + config.status: creating librule/Makefile + config.status: creating po/Makefile.in + config.status: creating src/Makefile + config.status: creating tools/Makefile + config.status: creating tools/port_counts/Makefile + config.status: creating tools/port_status/Makefile + config.status: creating tools/rule/Makefile + config.status: creating tools/reg_rw/Makefile + config.status: creating tools/debug/Makefile + config.status: creating examples/Makefile + config.status: creating examples/l2switch/Makefile + config.status: creating config.h + config.status: executing depfiles commands + config.status: executing default-1 commands + config.status: executing libtool commands + config.status: executing po/stamp-it commands + \end{code} + \item 编译 + \begin{code}[console] + openbox@OpenBox~/hnxs/fast-0.4.5$ make + make all-recursive + make[1]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5' + Making all in include + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/include' + make[2]: 没有什么可以做的为 `all'。 + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/include' + Making all in libreg + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/libreg' + CC main_libreg.o + AR libreg.a + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/libreg' + Making all in libua + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/libua' + CC main_libua.o + AR libua.a + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/libua' + Making all in librule + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/librule' + CC main_librule.o + AR librule.a + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/librule' + Making all in tools + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/tools' + Making all in port_counts + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/tools/port_counts' + CC main_port_counts.o + CCLD port_counts + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/tools/port_counts' + Making all in port_status + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/tools/port_status' + CC main_port_status.o + CCLD port_status + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/tools/port_status' + Making all in rule + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/tools/rule' + CC main_rule.o + CCLD rule + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/tools/rule' + Making all in reg_rw + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/tools/reg_rw' + CC main_reg_rw.o + CCLD reg_rw + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/tools/reg_rw' + Making all in debug + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/tools/debug' + CC main_debug.o + CCLD debug + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/tools/debug' + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/tools' + make[3]: 没有什么可以做的为 `all-am'。 + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/tools' + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/tools' + Making all in po + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/po' + make[2]: 没有什么可以做的为 `all'。 + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/po' + Making all in src + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/src' + CC fast-main.o + CCLD fast + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/src' + Making all in examples + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/examples' + Making all in l2switch + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/examples/l2switch' + CC main_l2switch.o + CCLD l2switch + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/examples/l2switch' + make[3]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5/examples' + make[3]: 没有什么可以做的为 `all-am'。 + make[3]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/examples' + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5/examples' + make[2]: 正在进入目录 `/home/openbox/hnxs/fast-0.4.5' + make[2]: 没有什么可以做的为 `all-am'。 + make[2]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5' + make[1]:正在离开目录 `/home/openbox/hnxs/fast-0.4.5' + \end{code} +\end{enumerate} + +\subsubsection{代码执行} +\begin{enumerate} + \item 读硬件版本号 + \begin{code}[console] + openbox@OpenBox~/hnxs/fast-0.4.5$ reg_rw rd 0 + \end{code} +\end{enumerate} + +\subsection{FAST数据结构} +\subsubsection{UM数据结构} +\begin{code}[c] + struct um_metadata{ + #if defined(__LITTLE_ENDIAN) /*INTER*/ + #ifdef FAST_10 + u64 ts:32, /**< @brief 报文接收的时间戳 @note 如果用户需要使用表示更大的时间,建议存储在第二拍数据中(user[2]字段)*/ + ts2:12, + flowID:14, /**< @brief 流ID号*/ + priority:3, /**< @brief 报文优先级*/ + discard:1, /**< @brief 指示报文是否丢弃 @note 默认为0,表示不丢弃,置1时表示丢弃*/ + pktdst:1, /**< @brief 报文的输出目的方向 @note 0表示输出到网络端口,1表示输出到CPU*/ + pktsrc:1; /**< @brief 报文的输入源方向 @note 0表示网络端口输入,1表示从CPU输入*/ + u64 outport:16, /**< @brief 报文输出端口号 @note 以bitmap形式表示,1表示从0号端口输出;8表示从3号端口输出*/ + seq:12, /**< @brief 报文接收时的序列号 @note 每个端口独立维护一个编号*/ + dstmid:8, /**< @brief 报文下次处理的目的模块编号*/ + srcmid:8, /**< @brief 报文上次处理时的模块编号*/ + len:12, /**< @brief 报文长度 @note 最大可表示4095字节,但FAST平台报文缓存区最大为2048,完整以太网报文的MTU不要超过1500*/ + inport:4, /**< @brief 输入端口号 @note 取值:0——15,最多表示16个输入端口*/ + ttl:4; /**< @brief 报文通过模块的TTL值,每过一个处理模块减1*/ + #elif FAST_20 + u64 ts:32, /**< @brief 时间戳*/ + reserve:17, /**< @brief 保留*/ + pktsrc:1, /**< @brief 分组的来源,0为网络接口输入,1为CPU输入,此比特位在进入硬件时会交换到pkttype位置,保留位为18位*/ + flowID:14; /**< @brief 流ID*/ + u64 seq:8, /**< @brief 分组接收序列号*/ + pst:8, /**< @brief 标准协议类型(参考硬件定义)*/ + dstmid:8, /**< @brief 下一个处理分组的模块ID*/ + srcmid:8, /**< @brief 最近一次处理分组的模块ID*/ + len:12, /**< @brief 报文长度*/ + discard:1, /**< @brief 丢弃位*/ + priority:3, /**< @brief 分组优先级*/ + outport:6, /**< @brief 单播:分组输出端口ID,组播/泛洪:组播/泛洪表地址索引*/ + outtype:2, /**< @brief 输出类型,00:单播,01:组播,10:泛洪,11:从输入接口输出*/ + inport:6, /**< @brief 分组的输入端口号*/ + pktdst:1, /**< @brief 分组目的,0为网络接口输出,1为送CPU*/ + pkttype:1; /**< @brief 报文类型,0:数据报文,1:控制报文。硬件识别报文类别后,会将pktsrc位交换到此,恢复硬件数据格式*/ + #endif + u64 user[2]; /**< @brief 用户自定义metadata数据格式与内容 @remarks 此字段由可用户改写,但需要保证数据大小严格限定在16字节*/ + #elif defined(__BIG_ENDIAN) /**/ + #error "(__BIG_ENDIAN)Please fix " + #else + #error "Please fix " + #endif + }; +\end{code} +\subsubsection{FAST报文数据结构} +\begin{code}[c] + struct fast_packet + { + union + { + struct um_metadata um; /**< @brief UM模块数据格式定义 @see ::um_metadata */ + struct ctl_metadata cm; /**< 控制报文格式定义*/ + struct common_metadata md; /**< 公共控制信息,报文类型(0:数据,1:控制)*/ + }; + #ifdef OPENBOX_S28 + u16 flag; /**< @brief 2字节对齐标志,主要是为了IP地址的对齐 @note 此标志在内核会用来标记是一个FAST类型报文,建议用户不使用些字段*/ + #endif + u8 data[1514]; /**< @brief 完整以太网报文数据,暂时不含CRC数据*/ + }; +\end{code} +\subsubsection{流关键字数据结构} +\begin{code}[c] + struct flow /*2017/06/01开始启用,支持IPv6*/ + { + u8 dmac[ETH_ALEN]; /**< @brief Ethernet source address. */ + u8 smac[ETH_ALEN]; /**< @brief Ethernet destination address. */ + u16 tci; /**< @brief 0 if no VLAN, VLAN_TAG_PRESENT set otherwise. */ + u16 type; /**< @brief Ethernet frame type. */ + //eth-16; + + u8 proto; /**< @brief IP protocol or lower 8 bits of ARP opcode. */ + u8 tos; /**< @brief IP ToS. */ + u8 ttl; /**< @brief IP TTL/hop limit. */ + u8 port:6, /**< @brief Input Port*/ + frag:2; /**< @brief One of OVS_FRAG_TYPE_*. */ + //ip=16+4; + + union { + struct { + u32 src; /**< @brief IP source address. */ + u32 dst; /**< @brief IP destination address. */ + //addr; + + union { + struct { + u16 sport; /**< @brief TCP/UDP/SCTP source port. */ + u16 dport; /**< @brief TCP/UDP/SCTP destination port. */ + u16 flags; /**< @brief TCP flags. */ + } tp; /**< @brief IPv4的传输层端口与标志信息*/ + struct { + u8 sha[ETH_ALEN]; /**< @brief ARP source hardware address. */ + u8 tha[ETH_ALEN]; /**< @brief ARP target hardware address. */ + } arp; /**< @brief ARP的MAC地址信息*/ + }; /**< @brief IPv4传输层信息与ARP信息共用体,二者互斥存在*/ + } ipv4; /**< @brief IPv4协议相关字段*/ + struct { + struct in6_addr src; /**< @brief IPv6 source address. */ + struct in6_addr dst; /**< @brief IPv6 destination address. */ + //addr; + + u32 label; /**< @brief IPv6 flow label. */ + union { + struct { + u16 sport; /**< @brief TCP/UDP/SCTP source port. */ + u16 dport; /**< @brief TCP/UDP/SCTP destination port. */ + u16 flags; /**< @brief TCP flags. */ + } tp; /**< @brief IPv6的传输层端口与标志信息*/ + /*512位宽表项不够,暂不使用ND协议中的targetIP!!!为方便以后扩展,将其移至末尾*/ + #if 0 + struct { + u8 sll[ETH_ALEN]; /**< @brief ND source link layer address. */ + u8 tll[ETH_ALEN]; /**< @brief ND target link layer address. */ + struct in6_xaddr target; /**< @brief ND target address. */ + } nd; + #endif + }; /**< @brief IPv6传输层信息与ND信息共用体,二者互斥存在*/ + u16 nil; + } ipv6; /**< @brief IPv6协议相关字段*/ + }; + }; +\end{code} +\subsubsection{流数据结构} +\begin{code}[c] + struct fast_rule{ + struct flow key; /**< @brief 规则内容存储结构 @see ::flow*/ + struct flow mask; /**< @brief 规则掩码设置结构,与key一一对应 @see ::flow*/ + u32 priority; /**< @brief 规则的优先级设置*/ + u32 valid; /**< @brief 规则的有效标志设置,要删除一条规则只需要将此标记置0,并更新到硬件*/ + u32 action; /**< @brief 规则所对应的执行动作,动作由两部分组成,高4位为ACTION枚举类型,低28位不此类型对应的值 @see ::ACTION*/ + /*此前数据必须要写入到硬件*/ + u32 flow_stats_len; /**< @brief 流表信息长度*/ + u64 *flow_stats_info; /**< @brief 流表信息存储指针位置*/ + #ifdef OPENBOX_S4 + u32 *tmp; /*在S4系统中,上面变量指针大小为32*/ + #endif + u64 cookie; /**< @brief 用来存储流的cookie信息,软件使用*/ + u64 cookie_mask; /**< @brief 用来存储流cookie的掩码信息,软件使用*/ + u32 md5[4]; /**< @brief MD5值 @note 用来区分规则的唯一性,软件生成规则时即会判断是否规则重复*/ + u32 pad[18]; /**< @brief 总长256B,此为确保数据结构大小做的填充*/ + }; +\end{code} + +\subsection{FAST开发函数} + +\subsubsection{硬件资源与寄存器} +\begin{enumerate} + \item int fast\_init\_hw(u64 addr,u64 len); + 硬件资源初始化。所有涉及到需要操作硬件寄存器、流表和动作等均需要先调用此函数, + 实例化硬件资源,使软件具体访问硬件的能力。 + + 参数:addr,在PCIe标准设备中表示硬件资源的内存映射地址, + 通常情况下,用户可以直接填写0。 + + 参数:len,在PCIe标准调和中表示硬件资源的内存地址空间大小, + 通常情况下,用户可以直接填写0。 + + 返回值:0表示硬件资源实例化正常,非零表示失败, + 如果失败将无法对硬件进行任何操作,程序将自动退出。 + \item void fast\_distroy\_hw(void); + 硬件资源销毁。PCIe设备主要是撤销对硬件资源的映射, + OpenBox-S4主要是对设备发送关闭报文。 + 一般情况下,用户程序退出时应该调用此函数,释放资源。 + 但是我们内部并没有做特殊的资源处理,均为系统可自动回收功能, + 即使用户不调用此函数,当程序正常退出时,系统也能正常回收资源, + 不影响程序再次运行使用。 + \item u64 fast\_reg\_rd(u64 regaddr); + 寄存器读函数。读取用户指定寄存器位置的值返回。 + 该函数内部会根据平台的不同使用不同的方法去访问硬件寄存器。 + PCIe的平台以正常寄存器方式访问,而NetMagic~08需要使用NMAC报文进行交互获取。 + 这些不同的操作方式均已对用户屏蔽,用户无需关心该函数底层如何交互与实现, + 仅需调用此函数接口来操作寄存器读操作即可。 + + 参数:regaddr,表示用户将要读取的寄存器地址, + 该地址即FAST平台所定义的虚拟地址空间,该值均使用相对偏移值的方式使用, + 即FAST平台定义的值,对PCIe平台设备访问需要使用绝对地址访问才可以正常访问寄存器, + 相对地址转绝对地址已经封装在函数内部, + 用户对所有寄存器的操作均可只用相对值访问即可。 + + 返回值:返回该寄存器对应的值。该值的位宽是64位, + 在所有FAST平台寄存器的位宽均为64位。 + \item void fast\_reg\_wr(u64 regaddr,u64 regvalue); + 寄存器写函数。将指定值写对硬件对应的寄存器位置。 + 该函数内部会根据平台的不同使用不同的方法去操作硬件寄存器。 + PCIe的平台以正常寄存器方式访问,而NetMagic~08需要使用NMAC报文进行交互获取。 + 这些不同的操作方式均已对用户屏蔽,用户无需关心该函数底层如何交互与实现, + 仅需调用此函数接口来操作寄存器写操作即可。 + + 参数:regaddr,表示用户将要写入的寄存器地址, + 该地址即FAST平台所定义的虚拟地址空间,该值均使用相对偏移值的方式使用, + 即FAST平台定义的值, + 对PCIe平台设备访问需要使用绝对地址访问才可以正常访问寄存器, + 相对地址转绝对地址已经封装在函数内部, + 用户对所有寄存器的操作均可只用相对值访问即可。 + + 参数:regvalue,表示要写入上述参数寄存器位置的值。该值的位宽为64位。 +\end{enumerate} +\subsubsection{流表操作} +\begin{enumerate} + \item void init\_rule(u32 default\_action); + 初始化规则。初始化规则函数的主要功能是在软件分配软件规则空间, + 将硬件规则空间清零,设置硬件规则的默认动作。 + 该函数只在进行流表操作的应用中进行调用,而且只能被调用一次。 + 如果有多个应用需要操作规则, + 整个系统在关机或重启前所有的应用中也只能由一个应用来调用一次。 + 主要是该函数会将硬件所有存在流表清空。用户需要自己非常清楚对流表的操作, + 在一次流表清空后才可以对流表进行其他操作。 + + 参数:default\_action,默认动作。当所有的流表均不能匹配时, + 硬件需要执行一个默认的动作来完成这个分组的处理, + 流表可以为空,但默认动作必须要有。详细的动作含义可以参考动作说明。 + + \item int fast\_add\_rule(struct fast\_rule *rule); + 添加一条规则。添加规则函数,先将用户的规则添加在软件流表中, + 经过各种比较判断后,看是否能正常添加,有无冲突或是否存在, + 如果可以正常添加,则先将规则存储在软件, + 然后将此条软件规则数据通过寄存器方式下发到硬件对应规则的存储位置。 + + 参数:rule,规则对象,内部具体字段参考流规则数据结构定义 + + 返回值:返回当前添加规则成功后此条规则所在的索引号 + \item int fast\_modify\_rule(struct fast\_rule *rule,int idx); + 修改一条已经存在的规则。此函数主要是用来修改已经存在的规则, + 对其关键字、掩码、动作和优先级等进行修改。 + 该函数的索引值参数如果指向一条空规则,其操作流程将类似于添加规则函数。 + + 参数:rule,新规则对象,内部具体字段参考流规则数据结构定义 + + 参数:idx,旧规则所在索引号 + + 返回值:返回输入参数的idx值说明操作成功,其他值说明操作失败 + \item int fast\_del\_rule(int idx); + 删除一条已经存储的规则,或将一条规则置为无效。 + 只需要提供规则所在的索引号,软件可通过索引号定位到对应硬件存储规则位置, + 将规则的有效位置为无效,实现一条规则的删除。 + 删除硬件成功后,将其对应的软件规则进行清除。 + + 参数:idx,删除规则所在索引号 + + 返回值:返回输入参数的idx值说明操作成功,其他值说明操作失败 + \item int read\_hw\_rule(struct fast\_rule *rule,int index); + 读取一条硬件规则。将存储在硬件规则内对应索引的数据读取出来, + 还原为一条软件规则数据,存储在用户提供的指针位置。 + + 参数:rule,将要存储规则的内存指针 + + 参数:idx,将要读取规则所在硬件的索引号 + + 返回值:返回输入参数的idx值说明操作成功,其他值说明操作失败 + \item void print\_hw\_rule(void); + 打印硬件所有规则信息。此函数是上一个读取硬件规则条目信息的集合操作, + 将所有硬件流规则信息一一读出,并打印输出在屏幕上。 +\end{enumerate} +\subsubsection{UA编程} +\begin{enumerate} + \item int fast\_ua\_init(int mid,fast\_ua\_recv\_callback callback); + UA编程初始化函数。 + \item void fast\_ua\_destroy(void); + UA编程注销函数。 + \item int fast\_ua\_send(struct fast\_packet *pkt,int pkt\_len); + UA程序发送报文函数 + \item void fast\_ua\_recv(); + 启动UA接收用户特征流程序函数 +\end{enumerate} + +\subsection{FAST虚拟地址空间定义} + +\subsubsection{debug um} +\begin{code}[c] + #define FAST_DEBUG_UM_DC FAST_HW_UM+0x0000 + #define FAST_DEBUG_UM_GPP FAST_HW_UM+0x2000 + #define FAST_DEBUG_UM_GKE FAST_HW_UM+0x4000 + #define FAST_DEBUG_UM_GME FAST_HW_UM+0x6000 + #define FAST_DEBUG_UM_GAC FAST_HW_UM+0x8400 + #define FAST_DEBUG_UM_GOE FAST_HW_UM+0xA000 + + /*GPP模块*/ + #define FAST_DEBUG_GPP_GPP_STATUS FAST_DEBUG_UM_GPP+0x00 + #define FAST_DEBUG_GPP_IN_GPP_DATA_COUNT FAST_DEBUG_UM_GPP+0x08 + #define FAST_DEBUG_GPP_OUT_GPP_MD_COUNT FAST_DEBUG_UM_GPP+0x10 + #define FAST_DEBUG_GPP_OUT_GPP_PHY_COUNT FAST_DEBUG_UM_GPP+0x18 + #define FAST_DEBUG_GPP_OUT_GPP_CACHE_COUNT FAST_DEBUG_UM_GPP+0x20 + + /*GKE模块*/ + #define FAST_DEBUG_GKE_GKE_STATUS FAST_DEBUG_UM_GKE+0x00 + #define FAST_DEBUG_GKE_IN_GKE_MD_COUNT FAST_DEBUG_UM_GKE+0x08 + #define FAST_DEBUG_GKE_IN_GKE_PHY_COUNT FAST_DEBUG_UM_GKE+0x10 + #define FAST_DEBUG_GKE_OUT_GKE_MD_COUNT FAST_DEBUG_UM_GKE+0x18 + #define FAST_DEBUG_GKE_OUT_GKE_PHY_COUNT FAST_DEBUG_UM_GKE+0x20 + #define FAST_DEBUG_GKE_OUT_GKE_KEY_COUNT FAST_DEBUG_UM_GKE+0x28 + + /*GME*/ + #define FAST_DEBUG_GME_GME_STATUS FAST_DEBUG_UM_GME+0x00 + #define FAST_DEBUG_GME_IN_GME_MD_COUNT FAST_DEBUG_UM_GME+0x08 + #define FAST_DEBUG_GME_IN_GME_PHY_COUNT FAST_DEBUG_UM_GME+0x10 + #define FAST_DEBUG_GME_IN_GME_KEY_COUNT FAST_DEBUG_UM_GME+0x18 + #define FAST_DEBUG_GME_IN_GME_INDEX_COUNT FAST_DEBUG_UM_GME+0x20 + #define FAST_DEBUG_GME_OUT_GME_MD_COUNT FAST_DEBUG_UM_GME+0x28 + #define FAST_DEBUG_GME_OUT_GME_PHY_COUNT FAST_DEBUG_UM_GME+0x30 + #define FAST_DEBUG_GME_OUT_GME_KEY_COUNT FAST_DEBUG_UM_GME+0x38 + + /*GAC*/ + #define FAST_DEBUG_GAC_GAC_STATUS FAST_DEBUG_UM_GAC+0x00 + #define FAST_DEBUG_GAC_IN_GAC_DATA_COUNT FAST_DEBUG_UM_GAC+0x08 + #define FAST_DEBUG_GAC_IN_GAC_MD_COUNT FAST_DEBUG_UM_GAC+0x10 + #define FAST_DEBUG_GAC_IN_GAC_PHY_COUNT FAST_DEBUG_UM_GAC+0x18 + #define FAST_DEBUG_GAC_OUT_GAC_DATA_COUNT FAST_DEBUG_UM_GAC+0x20 + #define FAST_DEBUG_GAC_OUT_GAC_PHY_COUNT FAST_DEBUG_UM_GAC+0x28 + + /*GOE*/ + #define FAST_DEBUG_GOE_GOE_STATUS FAST_DEBUG_UM_GOE+0x00 + #define FAST_DEBUG_GOE_IN_GOE_DATA_COUNT FAST_DEBUG_UM_GOE+0x08 + #define FAST_DEBUG_GOE_IN_GOE_PHY_COUNT FAST_DEBUG_UM_GOE+0x10 + #define FAST_DEBUG_GOE_OUT_GOE_DATA_COUNT FAST_DEBUG_UM_GOE+0x18 + + + #define FAST_DEBUG_DC_DATA_CACHE_STATUS FAST_DEBUG_UM_DC+0x00 + #define FAST_DEBUG_DC_IN_DATA_CACHE_COUNT FAST_DEBUG_UM_DC+0x08 + #define FAST_DEBUG_DC_OUT_DATA_CACHE_COUNT FAST_DEBUG_UM_DC+0x10 +\end{code} +\subsubsection{端口计数} +\begin{code}[c] + #define FAST_COUNTS_RECV_BYTE_L 0x200 /**< 计数寄存器:成功接收字节数低位计数*/ + #define FAST_COUNTS_RECV_BYTE_H 0x204 /**< 计数寄存器:成功接收字节数高位计数*/ + #define FAST_COUNTS_SEND_BYTE_L 0x208 /**< 计数寄存器:成功发送字节数低位计数*/ + #define FAST_COUNTS_SEND_BYTE_H 0x20C /**< 计数寄存器:成功发送字节数高位计数*/ + + #define FAST_COUNTS_RECV_PKT_L 0x290 /**< 计数寄存器:接收成功的计数*/ + #define FAST_COUNTS_RECV_PKT_H 0x294 /**< 计数寄存器:接收成功的计数*/ + #define FAST_COUNTS_SEND_PKT_L 0x2D8 /**< 计数寄存器:发送成功的计数*/ + #define FAST_COUNTS_SEND_PKT_H 0x2DC /**< 计数寄存器:发送成功的计数*/ +\end{code} +\subsubsection{硬件流表} +\begin{code}[c] + #define FAST_OFP_FLOW_STATS_PKTS 0x8B000 /*流表报文计数*/ + #define FAST_OFP_FLOW_STATS_BYTES 0x8B800 /*流表字节计数*/ +\end{code} +\subsubsection{硬件动作} +\begin{code}[c] + #define BASE_ADDR 0x43C00000 /**< 硬件资源起始地址*/ + #define REG_LEN 0x01000000 /**< 硬件资源可用空间*/ + #define FAST_ACTION_REG_ADDR 0x88000 /**< 写动作寄存器*/ + #define FAST_DEFAULT_RULE_ADDR 0x1F8 /**< 默认动作(匹配不到规则时执行默认动作)地址*/ +\end{code} + +\subsection{FAST开发流程} +基于FAST的软件代码开发有三种方式: +第一种是基于FAS的源代码进行修改,整个代码结构不变, +可以直接使用原工程中的所有Makefile文件, +修改完成后,直接make即可得到用户所需要的可执行文件; +第二种是用户根据自己需要,选择需要的开发库与头文件, +自己重新组织新的代码目录与结构进行开发, +原工程中的Makefile文件均不可再用,需要自己重写Makefile文件。 + +\subsubsection{修改源码开发} + +\begin{enumerate} + \item 已FAST的rule\_rw工具作为修改示例, + 修改fast/tools/rule\_rw/目录下main\_rule.c文件 + \item 修改main\_rule\_test函数, + 将两个端口互转硬件规则改为根据以太网类型来转发 + \begin{code}[c] + void main_rule_test(int argc,char *argv[]) + { + int i = 0,p1 = 1,p2 = 2,idx1 = 0,idx2 = 1; + struct fast_rule rule[2] = {{0},{0}};//初始化两条全空的规则 + + if(argc == 3) + { + p1 = atoi(argv[1]); + p2 = atoi(argv[2]); + } + else if(argc == 4) + { + p1 = atoi(argv[1]); + p2 = atoi(argv[2]); + idx1 = atoi(argv[3]); + } + else if(argc == 5) + { + p1 = atoi(argv[1]); + p2 = atoi(argv[2]); + idx1 = atoi(argv[3]); + idx2 = atoi(argv[4]); + } + + //给规则的各字段赋值 + rule[i].key.type = htole16(0x0800); //以太网类型 + rule[i].key.port = p1; + rule[i].priority =0xA; + rule[i].action = ACTION_PORT<<28|p2;//动作字段的涵义请参考fast_type.h + rule[i].md5[0] = i+1; + + //给规则对应字段设置掩码,掩码为1表示使用,为0表示忽略 + rule[i].mask.type = 0xFFFF; + rule[i].mask.port = 0x3F;/*6bit*/ + + //fast_add_rule(&rule[i]); + //fast_modify_rule(&rule[i],0); + + i++; + + rule[i].key.type = htole16(0x0800); + rule[i].key.port = p2; + rule[i].priority =0xB; + rule[i].action = ACTION_PORT<<28|p1;//动作字段的涵义请参考fast_type.h + rule[i].md5[0] = i+1; + + //给规则对应字段设置掩码,掩码为1表示使用,为0表示忽略 + rule[i].mask.type = 0xFFFF; + rule[i].mask.port = 0x3F; + + //fast_add_rule(&rule[i]); + //fast_modify_rule(&rule[i],1); + + + if(argc == 3 || argc == 1) + { + fast_modify_rule(&rule[i-1],idx1); + fast_modify_rule(&rule[i],idx2); + printf("Row[%d],Port[%d]----->Port[%d]\n",idx1,p1,p2); + printf("Row[%d],Port[%d]----->Port[%d]\n",idx2,p2,p1); + } + else if(argc == 4) + { + p1 = atoi(argv[1]); + p2 = atoi(argv[2]); + idx1 = atoi(argv[3]); + fast_modify_rule(&rule[i-1],idx1); + printf("Row[%d],Port[%d]----->Port[%d]\n",idx1,p1,p2); + } + else if(argc == 5) + { + p1 = atoi(argv[1]); + p2 = atoi(argv[2]); + idx1 = atoi(argv[3]); + idx2 = atoi(argv[4]); + fast_modify_rule(&rule[i-1],idx1); + fast_modify_rule(&rule[i],idx2); + printf("Row[%d],Port[%d]----->Port[%d]\n",idx1,p1,p2); + printf("Row[%d],Port[%d]----->Port[%d]\n",idx2,p2,p1); + } + } + \end{code} + + 修改保存退出,打开命令终端,跳到fast目录下,执行交叉编译 + + \begin{code}[console] + # cd fast-0.4.5 + # make + \end{code} + + 编译完成后将把tools/rule\_hw目录下rule\_hw工具放到OpenBox-S4设备, + 执行修改过的rule\_hw工具 + \begin{code}[console] + # ./rule_hw 0 1 + \end{code} + +\end{enumerate} + +\subsubsection{新增代码开发} + +用户基于FAST架构代码增加自己的软件代码, +建议按照完整项目工程管理的方法进行, +使用Anjuta开发软件进行修改和配置, +具体请参考《OpenBox-S4开发环境搭建手册》第三章anjuta 部署fast源代码。 + +\subsubsection{交叉编译代码} +OpenBox-S4平台为ARM嵌入式平台, +所运行软件需要通过交叉编译后才可放入平台运行。 +软件代码的交叉编译请参考《OpenBox-S4开发环境搭建手册》第二章的2.4节测试交叉编译。 \ No newline at end of file diff --git a/data/appendix/openbox.tex b/data/appendix/openbox.tex index be601e1..af18bc2 100644 --- a/data/appendix/openbox.tex +++ b/data/appendix/openbox.tex @@ -27,3 +27,432 @@ OpenBox-S4是一款软硬件全可编程网络实验平台, 内部软硬件用户逻辑支持所有FAST架构开发的应用、 标准的网络协议栈与通用网络应用。 平台软硬件逻辑代码开源免费,支持用户二次开发。 + +\subsection{设备上电检测} +当我们拿到设备后,并不知道这个设备有没有故障。 +所以在使用设备进行实验前,我们尽量简单并全面的对设备进行一次上电检测, +以确认设备是否没有故障。 + +\subsubsection{设备外部接口及其配件说明} +\begin{enumerate} + \item 设备外部接口,如下图所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f01} + \caption{正面外部接口} + \label{fig:a:ob_f01} + \end{figure} + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f02} + \caption{反面外部接口} + \label{fig:a:ob_f02} + \end{figure} + + \item 12V-1A电源线,如下图所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f03} + \caption{设备电源线} + \label{fig:a:ob_f03} + \end{figure} + + \item 串口线,如下图所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f04} + \caption{设备串口线} + \label{fig:a:ob_f04} + \end{figure} + + \item 设备烧录线,如下图所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f05} + \caption{设备烧录线} + \label{fig:a:ob_f05} + \end{figure} + +\end{enumerate} + +\subsubsection{检测准备} +\begin{enumerate} + \item 物品准备 + \begin{table}[!htp] + \small + \centering + \caption{以太网帧格式} + \label{tab:c:wireshark_eth-format} + \begin{tabular}{|c|c|} \hline + \heiti 测试项 & \heiti 所需物品 \\ \hline + 上电检测 & 一台设备及电源\\ \hline + 串口检测 & 一台设备及电源、一台电脑、一个micro usb 串口线\\ \hline + 管理网口(MGMT) & 一台设备及电源、一台电脑、一个网线\\ \hline + \end{tabular} + \end{table} +\end{enumerate} + +\subsubsection{上电检测} +\begin{enumerate} + \item 连接电源,将电源开关拨到ON(向右)。 + \item 观察电源指示灯变化情况: + \item 电源开关拨到ON(向右)后,CFG电源指示灯会亮一下; + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f06} + \caption{电源指示灯(刚接入电源)} + \label{fig:a:ob_f06} + \end{figure} + \item CFG电源指示灯过几秒后就灭了; + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f07} + \caption{电源指示灯(系统配置)} + \label{fig:a:ob_f07} + \end{figure} + 图 7 电源指示灯(系统配置) + \item 等待15秒左右,RUN电源指示灯常亮。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f08} + \caption{电源指示灯(系统运行)} + \label{fig:a:ob_f08} + \end{figure} +\end{enumerate} +\subsubsection{串口检测} +\begin{enumerate} + \item 确保micro usb串口线正确连接到设备上,并且设备已上电。 + \item 确保调试电脑已按照《01\_常用软件的安装使用手册.pdf》 + 文档进行了PUTTY串口终端工具的安装。 + \item 确保调试电脑已按照《01\_常用软件的安装使用手册.pdf》 + 文档进行了CP2102驱动的安装。 + \item 在电脑的设备管理器,查看设备的COM口数值。 + (如下图,设备成的COM口数值为COM4,不同的电脑显示的COM口数值会不同) + \item 打开PUTTY工具界面。 + \begin{enumerate} + \item 先点击左边“category”栏的 “serial”选项; + \item 在“Serial line to connect to ”栏,填写设备管理器中看到的COM数值; + \item 在“Speed”栏,填写串口的波特率为“115200”; + \item 在 “Data bits”栏。填写数据位宽为“8”; + \item 在“Flow control”栏,选择“None”。 + \item 如下所示,调试电脑的COM数值为COM3,所以“serial line”栏填写为“COM3”。 + (不同电脑的COM数值可能不同,请填写实际的COM数值) + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f09} + \caption{putty软件串口配置参数} + \label{fig:a:ob_f09} + \end{figure} + \end{enumerate} +\item 点击 “open” ,进入设备系统,则串口测试OK。 +\end{enumerate} +\subsubsection{管理网口检测} +\begin{enumerate} + \item 使用一根网线,将调试电脑与设备的obx0口连接。 + \item + \item 设备的eth0网口的默认ip地址为:192.168.50.5, + 所以需要将调试电脑的ip地址设置成与设备eth0网口的ip地址在同一个网段下 + (也就是192.168.50网段)。 + \item 在调试电脑的 控制面板->网络和Internet->网络设备中。 + 点击以太网->属性->internet协议版本4(TCP/IPV4),进行ip地址的配置。如下所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f10} + \caption{配置以太网的ip地址} + \label{fig:a:ob_f10} + \end{figure} + 图 10 配置以太网的ip地址 + \item 在调试电脑的 控制面板>系统和安全>Windows Defender 防火墙>自定义设置中。 + 关闭调试电脑的防火墙功能。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f11} + \caption{关闭防火墙功能} + \label{fig:a:ob_f11} + \end{figure} + \item 在调试电脑的CMD终端下,使用ping命令能正常与eth0网口通讯, + 则说明管理网络检测OK。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f12} + \caption{ping 命令测试网络连通性} + \label{fig:a:ob_f12} + \end{figure} + +\end{enumerate} +\subsection{搭建环境} +OpenBox-S4是一款软硬件全可编程网络实验平台, +根据FAST架构搭建其软硬件基础运行环境, +内部软硬件用户逻辑支持所有FAST架构开发的应用, +是一款专业的网络实验与研究验证平台。 +\subsubsection{连接二层交换拓扑} + +\begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f13} + \caption{二层交换连接拓扑示意图} + \label{fig:a:ob_f13} +\end{figure} + +其中PC1的IP地址设置为“192.168.1.20”,PC2的IP地址设置为“192.168.1.21” +\subsubsection{在OpenBox-S4上运行二层交换程序} + +\begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f14} + \caption{二层交换命令启动输出图} + \label{fig:a:ob_f14} +\end{figure} + +在串口登录界面或网络登录界面输入命令:l2switch + +\begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f15} + \caption{二层交换命令运行输出图} + \label{fig:a:ob_f15} +\end{figure} + +\subsubsection{在PC两端进行PING测试} + +\begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f16} + \caption{端主机PING通结果图} + \label{fig:a:ob_f16} +\end{figure} + +\subsection{常用软件安装与使用} +\subsubsection{Wireshark抓包工具的安装使用} +\begin{enumerate} + \item 安装教程 + \begin{enumerate} + \item 进入“\\06\_软件包及工具\\抓包工具”目录。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f17} + \caption{Wireshark安装包路径} + \label{fig:a:ob_f17} + \end{figure} + \item 鼠标双击Wireshark-win64-3.2.5.exe文件, + 进入到下图中的安装界面。直接点击“agree”进行下一步。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f18} + \caption{Wireshark许可协议} + \label{fig:a:ob_f18} + \end{figure} + \item 选择软件的安装路径。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f19} + \caption{更改Wireshark安装路径} + \label{fig:a:ob_f19} + \end{figure} + \item 点击 “install”进行安装。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f20} + \caption{Wireshark 开始安装} + \label{fig:a:ob_f20} + \end{figure} + \item 弹出Npacp组件安装窗口,点击 “install”进行安装。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f21} + \caption{Wireshark 安装Npacp组件} + \label{fig:a:ob_f21} + \end{figure} + \end{enumerate} + \item 使用教程 + \begin{enumerate} + \item 捕获网络接口 + \begin{enumerate} + \item 打开安装好的wireshark,会进入如下所示界面。 + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f22} + \caption{Wireshark启动界面说明} + \label{fig:a:ob_f22} + \end{figure} + + \item 这里以有线网口为例,则点击选择 “以太网”, + 就可以捕获有线网口的所有数据报文。如下所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f23} + \caption{以太网接口捕获数据报文情况} + \label{fig:a:ob_f23} + \end{figure} + \end{enumerate} + \item wireshark 窗口介绍 + wireshark主要分为这几个窗口,如下所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f24} + \caption{Wireshark窗口说明} + \label{fig:a:ob_f24} + \end{figure} + \begin{enumerate} + \item Display Filter(显示过滤器):用于设置过滤条件进行数据包列表过滤。 + \item Packet List Pane(封包列表):简要地显示捕获到的数据包, + 每个数据包包含编号,时间戳,源地址,目标地址,协议,长度,以及数据包信息。 + 不同协议的数据包使用了不同的颜色区分显示。。 + \item Packet Details Pane(封包详细信息):在数据包列表中选择指定数据包, + 在数据包详细信息中会显示数据包的所有详细信息内容。 + 数据包详细信息面板是最重要的,用来查看协议中的每一个字段。 + \item Packet Bytes Pane(16进制数据):以十六进制和ASCII码的形式显示数据包的内容。 + 这里显 示了一个数据包未经处理的原始样子,也就是在链路上传播时的数据形式。 + \item Miscellanous(状态栏):包含有专家信息、注释、包的数量和Profile。 + \end{enumerate} + \item 过滤报文 + \begin{enumerate} + \item 在显示过滤器栏中,输入指定地过滤条件即可过滤报文。 + \item 如过滤ip地址为“192.168.1.1”的报文, + 则输入过滤条件“ip.addr == 192.168.1.1”。如下所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f25} + \caption{过滤指定ip地址报文} + \label{fig:a:ob_f24} + \end{figure} + \item 如过滤mac地址为“01:00:5e:7f:ff:fa”的报文, + 则输入过滤条件 “eth.addr == 01:00:5e:7f:ff:fa”如下所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f26} + \caption{过滤指定mac地址报文} + \label{fig:a:ob_f24} + \end{figure} + \item 由于篇幅的原因,wireshark的其他使用,在本文档就不再说明了。 + \end{enumerate} + \end{enumerate} +\end{enumerate} +\subsubsection{CP2102串口驱动的安装使用} +\begin{enumerate} + \item 在“06\_软件包及工具/CP2102串口驱动”目录下, + 根据电脑的操作系统选择对应的软件包。 + \item 如以windows~10操作系统的电脑为例, + 则选择 “06\_软件包及工具/CP2102串口驱动/win10版/CP210x\_Windows10\_Driver.zip”。 + 如下所示。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f27} + \caption{CP2102串口驱动压缩包} + \label{fig:a:ob_f27} + \end{figure} + \item 解压软件包,若根据系统为64位,则双击“CP210xVCPInstaller\_x64.exe”运行安装。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f28} + \caption{解压CP2102串口驱动压缩包} + \label{fig:a:ob_f28} + \end{figure} + \item 如下所示,完成安装。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f29} + \caption{CP2102串口驱动完成安装} + \label{fig:a:ob_f29} + \end{figure} +\end{enumerate} +\subsection{系统更新} +\subsubsection{系统组成} +OpenBox-S4的系统架构为通用多核CPU加FPGA, +使用的是Xilinx公司的ZYNQ系列芯片提供的整体封装解决方案。 +在ZYNQ芯片中包含CPU系统与FPGA系统两部分,其内部通过高速总线连接。 +在OpenBox-S4的设备中,其管理接口(MGMT)由CPU引出,其他4个标准网口则由FPGA引出。 + +整个系统的逻辑运行是从SD卡中的几个文件开始, +主要包括:BOOT.bin、devicetree.dtb、uImage和uramdisk.image.gz四个部分。 +其中BOOT.bin定义的整个芯片的物理系统构成、连接关系和FPGA的功能逻辑; +devicetree.dtb文件则定义了系统的硬件资源定义,在CPU运行系统内核镜像时, +提供外设硬件及资源定义参数;uImage是CPU运行的系统内核镜像文件, +提供linux的内核运行环境及外设驱动;uramdisk.image.gz是linux系统的根文件系统, +包含内核引导起来后所使用的存储根文件系统、 +系统配置信息、系统命令工具和用户命令等。 + +在所有的OpenBox-S4设备的系统中,BOOT.bin与devicetree.dtb是匹配成套生成的, +uImage和uramdisk.image.gz是所有系统通用匹配使用的。 +用户如果要修改芯片系统架构、连接以及硬件逻辑, +则需要重新生成BOOT.bin和devicetree.dtb文件,替换原来系统的这两件文件, +即可重新定义设备的硬件逻辑功能。如果需要重新定义系统内核功能, +则需要重新编译生成uImage文件进行替换。如果是用户软件逻辑或工具命令, +则可随时通过网络、U盘等上传至系统/mnt/openbox/目录即可使用。 + +\subsubsection{系统更新} +如上节所述,更新系统最多是替换该设备环境中的4个核心文件, +通常用户只修改硬件逻辑就不需要替换uImage和uramdisk.image.gz文件, +如果不调修改原有接口的地址资源配置地址,也无需devicetree.dtb文件, +仅需要更新替换Boot.bin文件即可。此文档主要描述一下, +如何更新整个系统运行环境,即替换系统的4个核心文件。 + +\begin{enumerate} + \item 备份系统原有系统核心文件 + 通过设备的管理接口连接到用户操作主机, + 通过SCP远程复制的方法将OpenBox-S4的系统备份到用户主机本地保存。 + Windows主机请使用putty配套的pscp命令工具,用法相同。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f30} + \caption{下载备份原有系统} + \label{fig:a:ob_f30} + \end{figure} + \item 上传用户新的系统核心文件 + + 将用户修改系统硬件逻辑后生成的BOOT.bin和devicetree.dtb + 文件保存在本地update目录中, + 将备份目录中的uImage和uramdisk.image.gz文件复制到update目录, + 确保update更新目录中包含OpenBox-S4系统运行环境的4个核心文件, + 其中BOOT.bin和devicetree.dtb是用户最新生成的。执行如下命令, + 将更新目录的4个核心文件上传替换原来OpenBox-S4上面的核心文件。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f31} + \caption{上传更新用户系统} + \label{fig:a:ob_f31} + \end{figure} + \item 断电后重启设备验证系统 + + 确认更新文件已经上传后,即可关机、断电和重新加电进行测试。 + + 重新加电进入系统后,使用系统自带工具读取硬件系统版本号。 + 如果其版本号读出与你的硬件逻辑定义一致,则说明系统更新成功。 + 如果不同说明系统更新没有替换原来的文件,请检查上传操作是否与上述截图一致, + 是否有报错信息。系统自带标准五级流水线版本号为0x2020181108, + 如下图所示,即说明系统更新成功 + (当前运行系统的硬件版本号为用户更新版本号:0x2020191231)。 + + \begin{figure}[!htp] + \centering + \includegraphics[width=11cm]{f32} + \caption{读硬件版本号验证} + \label{fig:a:ob_f32} + \end{figure} +\end{enumerate} diff --git a/figure/appendixes/openbox/f01.png b/figure/appendixes/openbox/f01.png new file mode 100644 index 0000000..c92df2c Binary files /dev/null and b/figure/appendixes/openbox/f01.png differ diff --git a/figure/appendixes/openbox/f02.png b/figure/appendixes/openbox/f02.png new file mode 100644 index 0000000..3f6f1a8 Binary files /dev/null and b/figure/appendixes/openbox/f02.png differ diff --git a/figure/appendixes/openbox/f03.png b/figure/appendixes/openbox/f03.png new file mode 100644 index 0000000..2360ba9 Binary files /dev/null and b/figure/appendixes/openbox/f03.png differ diff --git a/figure/appendixes/openbox/f04.png b/figure/appendixes/openbox/f04.png new file mode 100644 index 0000000..149bb7d Binary files /dev/null and b/figure/appendixes/openbox/f04.png differ diff --git a/figure/appendixes/openbox/f05.png b/figure/appendixes/openbox/f05.png new file mode 100644 index 0000000..6c9bab7 Binary files /dev/null and b/figure/appendixes/openbox/f05.png differ diff --git a/figure/appendixes/openbox/f06.png b/figure/appendixes/openbox/f06.png new file mode 100644 index 0000000..cea7720 Binary files /dev/null and b/figure/appendixes/openbox/f06.png differ diff --git a/figure/appendixes/openbox/f07.png b/figure/appendixes/openbox/f07.png new file mode 100644 index 0000000..b9d20a5 Binary files /dev/null and b/figure/appendixes/openbox/f07.png differ diff --git a/figure/appendixes/openbox/f08.png b/figure/appendixes/openbox/f08.png new file mode 100644 index 0000000..c67efbe Binary files /dev/null and b/figure/appendixes/openbox/f08.png differ diff --git a/figure/appendixes/openbox/f09.png b/figure/appendixes/openbox/f09.png new file mode 100644 index 0000000..2e64974 Binary files /dev/null and b/figure/appendixes/openbox/f09.png differ diff --git a/figure/appendixes/openbox/f10.png b/figure/appendixes/openbox/f10.png new file mode 100644 index 0000000..31ddcb9 Binary files /dev/null and b/figure/appendixes/openbox/f10.png differ diff --git a/figure/appendixes/openbox/f11.png b/figure/appendixes/openbox/f11.png new file mode 100644 index 0000000..ee5a310 Binary files /dev/null and b/figure/appendixes/openbox/f11.png differ diff --git a/figure/appendixes/openbox/f12.png b/figure/appendixes/openbox/f12.png new file mode 100644 index 0000000..ddd98f8 Binary files /dev/null and b/figure/appendixes/openbox/f12.png differ diff --git a/figure/appendixes/openbox/f13.png b/figure/appendixes/openbox/f13.png new file mode 100644 index 0000000..315c25b Binary files /dev/null and b/figure/appendixes/openbox/f13.png differ diff --git a/figure/appendixes/openbox/f14.png b/figure/appendixes/openbox/f14.png new file mode 100644 index 0000000..fb2fdd2 Binary files /dev/null and b/figure/appendixes/openbox/f14.png differ diff --git a/figure/appendixes/openbox/f15.png b/figure/appendixes/openbox/f15.png new file mode 100644 index 0000000..1d46ca8 Binary files /dev/null and b/figure/appendixes/openbox/f15.png differ diff --git a/figure/appendixes/openbox/f16.png b/figure/appendixes/openbox/f16.png new file mode 100644 index 0000000..408ed26 Binary files /dev/null and b/figure/appendixes/openbox/f16.png differ diff --git a/figure/appendixes/openbox/f17.png b/figure/appendixes/openbox/f17.png new file mode 100644 index 0000000..f8604e9 Binary files /dev/null and b/figure/appendixes/openbox/f17.png differ diff --git a/figure/appendixes/openbox/f18.png b/figure/appendixes/openbox/f18.png new file mode 100644 index 0000000..ed563b7 Binary files /dev/null and b/figure/appendixes/openbox/f18.png differ diff --git a/figure/appendixes/openbox/f19.png b/figure/appendixes/openbox/f19.png new file mode 100644 index 0000000..0468a3a Binary files /dev/null and b/figure/appendixes/openbox/f19.png differ diff --git a/figure/appendixes/openbox/f20.png b/figure/appendixes/openbox/f20.png new file mode 100644 index 0000000..b3ee7a7 Binary files /dev/null and b/figure/appendixes/openbox/f20.png differ diff --git a/figure/appendixes/openbox/f21.png b/figure/appendixes/openbox/f21.png new file mode 100644 index 0000000..3866bbf Binary files /dev/null and b/figure/appendixes/openbox/f21.png differ diff --git a/figure/appendixes/openbox/f22.png b/figure/appendixes/openbox/f22.png new file mode 100644 index 0000000..7ae9490 Binary files /dev/null and b/figure/appendixes/openbox/f22.png differ diff --git a/figure/appendixes/openbox/f23.png b/figure/appendixes/openbox/f23.png new file mode 100644 index 0000000..241deaf Binary files /dev/null and b/figure/appendixes/openbox/f23.png differ diff --git a/figure/appendixes/openbox/f24.png b/figure/appendixes/openbox/f24.png new file mode 100644 index 0000000..b30dccc Binary files /dev/null and b/figure/appendixes/openbox/f24.png differ diff --git a/figure/appendixes/openbox/f25.png b/figure/appendixes/openbox/f25.png new file mode 100644 index 0000000..40e1eb6 Binary files /dev/null and b/figure/appendixes/openbox/f25.png differ diff --git a/figure/appendixes/openbox/f26.png b/figure/appendixes/openbox/f26.png new file mode 100644 index 0000000..a21459b Binary files /dev/null and b/figure/appendixes/openbox/f26.png differ diff --git a/figure/appendixes/openbox/f27.png b/figure/appendixes/openbox/f27.png new file mode 100644 index 0000000..83ba863 Binary files /dev/null and b/figure/appendixes/openbox/f27.png differ diff --git a/figure/appendixes/openbox/f28.png b/figure/appendixes/openbox/f28.png new file mode 100644 index 0000000..4aa8f2a Binary files /dev/null and b/figure/appendixes/openbox/f28.png differ diff --git a/figure/appendixes/openbox/f29.png b/figure/appendixes/openbox/f29.png new file mode 100644 index 0000000..f6a713b Binary files /dev/null and b/figure/appendixes/openbox/f29.png differ diff --git a/figure/appendixes/openbox/f30.png b/figure/appendixes/openbox/f30.png new file mode 100644 index 0000000..0c26214 Binary files /dev/null and b/figure/appendixes/openbox/f30.png differ diff --git a/figure/appendixes/openbox/f31.png b/figure/appendixes/openbox/f31.png new file mode 100644 index 0000000..1cce3d1 Binary files /dev/null and b/figure/appendixes/openbox/f31.png differ diff --git a/figure/appendixes/openbox/f32.png b/figure/appendixes/openbox/f32.png new file mode 100644 index 0000000..ec5dcdd Binary files /dev/null and b/figure/appendixes/openbox/f32.png differ