From 217c3cd488f0d5867fc129b136630d563406d122 Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Tue, 24 Apr 2018 10:30:37 +1000 Subject: [PATCH 1/4] Added Port Stats interval config setting --- ZodiacFX/src/command.c | 24 ++++++++++++++++++++++++ ZodiacFX/src/command.h | 1 + ZodiacFX/src/config/config_zodiac.h | 3 +-- ZodiacFX/src/main.c | 1 + 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 7e60610..75ca9b9 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -451,6 +451,9 @@ void command_root(char *command, char *param1, char *param2, char *param3) // Force OpenFlow version reset_config.of_version = 0; // Force version disabled + + //How often to retrieve stats from switch + reset_config.stats_interval = 1; // Default 1 second memcpy(&reset_config.MAC_address, &Zodiac_Config.MAC_address, 6); // Copy over existing MAC address so it is not reset memcpy(&Zodiac_Config, &reset_config, sizeof(struct zodiac_config)); @@ -485,6 +488,7 @@ void command_root(char *command, char *param1, char *param2, char *param3) } if (Zodiac_Config.ethtype_filter == 1) printf(" EtherType Filtering: Enabled\r\n"); if (Zodiac_Config.ethtype_filter != 1) printf(" EtherType Filtering: Disabled\r\n"); + printf(" Port Stats Interval: %d\r\n" , Zodiac_Config.stats_interval); printf("\r\n\n"); return; } @@ -589,6 +593,7 @@ void command_config(char *command, char *param1, char *param2, char *param3) } if (Zodiac_Config.ethtype_filter == 1) printf(" EtherType Filtering: Enabled\r\n"); if (Zodiac_Config.ethtype_filter != 1) printf(" EtherType Filtering: Disabled\r\n"); + printf(" Port Stats Interval: %d\r\n" , Zodiac_Config.stats_interval); printf("\r\n-------------------------------------------------------------------------\r\n\n"); return; } @@ -942,6 +947,9 @@ void command_config(char *command, char *param1, char *param2, char *param3) // Force OpenFlow version reset_config.of_version = 0; // Force version disabled + //How often to retrieve stats from switch + reset_config.stats_interval = 1; // Default 1 second + memcpy(&reset_config.MAC_address, &Zodiac_Config.MAC_address, 6); // Copy over existng MAC address so it is not reset memcpy(&Zodiac_Config, &reset_config, sizeof(struct zodiac_config)); saveConfig(); @@ -998,7 +1006,23 @@ void command_config(char *command, char *param1, char *param2, char *param3) } return; } + + // Set port stats update interval + if (strcmp(command, "set")==0 && strcmp(param1, "stats-interval")==0) + { + int interval; + sscanf(param2, "%d", &interval); + if (interval < 31 && interval > -1) + { + Zodiac_Config.stats_interval = interval; + printf("Port stats interval set to %d\r\n" , Zodiac_Config.stats_interval); + } else { + printf("Invalid value\r\n"); + } + return; + } + // Unknown Command printf("Unknown command\r\n"); return; diff --git a/ZodiacFX/src/command.h b/ZodiacFX/src/command.h index bee2417..6da5813 100644 --- a/ZodiacFX/src/command.h +++ b/ZodiacFX/src/command.h @@ -72,6 +72,7 @@ struct zodiac_config { uint8_t failstate; uint8_t of_version; uint8_t ethtype_filter; + uint8_t stats_interval; } PACK_STRUCT_STRUCT; PACK_STRUCT_END diff --git a/ZodiacFX/src/config/config_zodiac.h b/ZodiacFX/src/config/config_zodiac.h index 273d66c..3db9a9f 100644 --- a/ZodiacFX/src/config/config_zodiac.h +++ b/ZodiacFX/src/config/config_zodiac.h @@ -31,7 +31,7 @@ #define CONFIG_ZODIAC_H_ -#define VERSION "0.84" // Firmware version number +#define VERSION "0.85_A" // Firmware version number #define TOTAL_PORTS 4 // Total number of physical ports on the Zodiac FX @@ -48,7 +48,6 @@ #define MAX_BUCKETS 4 // Maximum number of group action buckets for OpenFlow 1.3 and higher #define HB_INTERVAL 2 // Number of seconds between heartbeats - #define HB_TIMEOUT 6 // Number of seconds to wait when there is no response from the controller #define MAX_OF_STATS 15 // Maximum number of flows to send to controller diff --git a/ZodiacFX/src/main.c b/ZodiacFX/src/main.c index 4010674..f24607d 100644 --- a/ZodiacFX/src/main.c +++ b/ZodiacFX/src/main.c @@ -139,6 +139,7 @@ int main (void) membag_init(); loadConfig(); // Load Config + if (Zodiac_Config.stats_interval > 30) Zodiac_Config.stats_interval = 1; // If this value has never been set make it the default of 1 IP4_ADDR(&x_ip_addr, Zodiac_Config.IP_address[0], Zodiac_Config.IP_address[1],Zodiac_Config.IP_address[2], Zodiac_Config.IP_address[3]); IP4_ADDR(&x_net_mask, Zodiac_Config.netmask[0], Zodiac_Config.netmask[1],Zodiac_Config.netmask[2], Zodiac_Config.netmask[3]); From 91dbb4667618ebc3b93481397378543e1f4ebe89 Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Tue, 24 Apr 2018 11:28:00 +1000 Subject: [PATCH 2/4] Changed port update timer --- ZodiacFX/src/openflow/of_helper.c | 34 +++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/ZodiacFX/src/openflow/of_helper.c b/ZodiacFX/src/openflow/of_helper.c index c740f01..9976c6d 100644 --- a/ZodiacFX/src/openflow/of_helper.c +++ b/ZodiacFX/src/openflow/of_helper.c @@ -68,7 +68,8 @@ extern uint8_t *ofp13_oxm_inst[MAX_FLOWS_13]; extern uint16_t ofp13_oxm_inst_size[MAX_FLOWS_13]; // Local Variables -uint8_t timer_alt; +uint8_t timer_alt = 0; +uint8_t update_interval = 0; static uint16_t VLAN_VID_MASK = 0x0fff; static inline uint64_t (htonll)(uint64_t n) @@ -139,21 +140,24 @@ void nnOF_timer(void) { totaltime ++; // Because this is called every 500ms totaltime is actually 2 x the real time // Round robin the timer events so they don't have such a big impact on switching - if (timer_alt == 0){ - update_port_stats(); - timer_alt = 1; - } else if (timer_alt == 1){ - update_port_status(); - // If port status has changed send a port status message - for (int x=0;x Zodiac_Config.stats_interval) + { + if (timer_alt == 0){ + if (Zodiac_Config.stats_interval > 0) update_port_stats(); + timer_alt = 1; + } else if (timer_alt == 1){ + flow_timeouts(); + if (Zodiac_Config.stats_interval > 0) update_port_status(); + // If port status has changed send a port status message + for (int x=0;x Date: Tue, 11 Jun 2019 11:52:13 +1000 Subject: [PATCH 3/4] Fixed Echo Reply Data --- ZodiacFX/src/command.c | 1 + ZodiacFX/src/openflow/openflow.c | 15 ++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ZodiacFX/src/command.c b/ZodiacFX/src/command.c index 75ca9b9..13f402d 100644 --- a/ZodiacFX/src/command.c +++ b/ZodiacFX/src/command.c @@ -1958,6 +1958,7 @@ void printhelp(void) printf(" delete vlan-port \r\n"); printf(" set of-version \r\n"); printf(" set ethertype-filter \r\n"); + printf(" set stats-interval \r\n"); printf(" factory reset\r\n"); printf(" exit\r\n"); printf("\r\n"); diff --git a/ZodiacFX/src/openflow/openflow.c b/ZodiacFX/src/openflow/openflow.c index 7beff68..495c6d6 100644 --- a/ZodiacFX/src/openflow/openflow.c +++ b/ZodiacFX/src/openflow/openflow.c @@ -81,7 +81,7 @@ bool rcv_freq; // Internal Functions void OF_hello(void); void echo_request(void); -void echo_reply(uint32_t xid); +void echo_reply(struct ofp_header *ofph, int size, int len); err_t TCPready(void *arg, struct tcp_pcb *tpcb, err_t err); void tcp_error(void * arg, err_t err); static err_t of_receive(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t err); @@ -190,7 +190,7 @@ static err_t of_receive(void *arg, struct tcp_pcb *tpcb, struct pbuf *p, err_t e break; case OFPT10_ECHO_REQUEST: - echo_reply(ofph->xid); + echo_reply(ofph, size, len); break; default: @@ -259,15 +259,12 @@ void OF_hello(void) * @param xid - transaction ID * */ -void echo_reply(uint32_t xid) +void echo_reply(struct ofp_header *ofph, int size, int len) { - struct ofp_header echo; - echo.version = OF_Version; - echo.length = HTONS(sizeof(echo)); - echo.type = OFPT10_ECHO_REPLY; - echo.xid = xid; + // Change the message type to Echo Reply and return any data that was sent + ofph->type = OFPT10_ECHO_REPLY; TRACE("openflow.c: Sent ECHO reply"); - sendtcp(&echo, sizeof(echo), 1); + sendtcp(ofph, len, 1); return; } From 9bcfdea7425021d5d050e3060ca5185be93c6c11 Mon Sep 17 00:00:00 2001 From: Paul Zanna Date: Tue, 11 Jun 2019 12:33:43 +1000 Subject: [PATCH 4/4] Version number change --- ZodiacFX/src/config/config_zodiac.h | 2 +- ZodiacFX/src/http.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ZodiacFX/src/config/config_zodiac.h b/ZodiacFX/src/config/config_zodiac.h index 3db9a9f..5c68505 100644 --- a/ZodiacFX/src/config/config_zodiac.h +++ b/ZodiacFX/src/config/config_zodiac.h @@ -31,7 +31,7 @@ #define CONFIG_ZODIAC_H_ -#define VERSION "0.85_A" // Firmware version number +#define VERSION "0.85" // Firmware version number #define TOTAL_PORTS 4 // Total number of physical ports on the Zodiac FX diff --git a/ZodiacFX/src/http.c b/ZodiacFX/src/http.c index cb24118..c9400a2 100644 --- a/ZodiacFX/src/http.c +++ b/ZodiacFX/src/http.c @@ -746,6 +746,9 @@ static err_t http_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err // Force OpenFlow version reset_config.of_version = 0; // Force version disabled + + //How often to retrieve stats from switch + reset_config.stats_interval = 1; // Default 1 second memcpy(&reset_config.MAC_address, &Zodiac_Config.MAC_address, 6); // Copy over existing MAC address so it is not reset memcpy(&Zodiac_Config, &reset_config, sizeof(struct zodiac_config));