5 #ifndef __OF1X_ACTION_PP_H__
6 #define __OF1X_ACTION_PP_H__
13 #include "../../../util/pp_guard.h"
19 #include "../../../physical_switch.h"
20 #include "../../../util/logging.h"
22 #include "../../../common/protocol_constants.h"
23 #include "../../../common/ternary_fields.h"
24 #include "../../../common/bitmap.h"
26 #include "../../../platform/lock.h"
27 #include "../../../platform/likely.h"
28 #include "../../../platform/memory.h"
29 #include "../../../platform/packet.h"
31 #include "../of1x_async_events_hooks.h"
64 pkt_write_actions->num_of_actions = 0;
72 for(i=0,j=0;i<entry_write_actions->num_of_actions && j < OF1X_AT_NUMBER;j++){
75 packet_write_actions->actions[j].__field = entry_write_actions->actions[j].__field;
76 packet_write_actions->actions[j].group = entry_write_actions->actions[j].group;
77 packet_write_actions->actions[j].type = entry_write_actions->actions[j].type;
80 packet_write_actions->num_of_actions++;
90 pkt_write_actions->num_of_actions = 0;
97 static inline void __of1x_process_group_actions(
const unsigned int tid,
const struct of1x_switch* sw,
const unsigned int table_id,
datapacket_t *pkt, uint64_t field,
of1x_group_t *group,
bool replicate_pkts){
105 case OF1X_GROUP_TYPE_ALL:
107 for (it_bk = group->bc_list->head; it_bk!=NULL;it_bk = it_bk->next){
110 if(it_bk->actions->num_of_output_actions == 0)
116 if(unlikely(pkt_replica == NULL)){
122 __of1x_process_apply_actions(tid, sw, table_id, pkt_replica, it_bk->actions, it_bk->actions->num_of_output_actions > 1, NULL);
125 if(it_bk->actions->num_of_output_actions > 1)
129 case OF1X_GROUP_TYPE_SELECT:
133 case OF1X_GROUP_TYPE_INDIRECT:
135 __of1x_process_apply_actions(tid, sw,table_id,pkt,group->bc_list->head->actions, replicate_pkts, NULL);
138 case OF1X_GROUP_TYPE_FF:
157 switch(action->type){
158 case OF1X_AT_NO_ACTION: assert(0);
165 case OF1X_AT_POP_VLAN:
169 case OF1X_AT_POP_MPLS:
175 case OF1X_AT_PUSH_MPLS:
179 case OF1X_AT_PUSH_VLAN:
185 case OF1X_AT_COPY_TTL_OUT:
189 case OF1X_AT_DEC_NW_TTL:
193 case OF1X_AT_DEC_MPLS_TTL:
197 case OF1X_AT_SET_MPLS_TTL:
201 case OF1X_AT_SET_NW_TTL:
207 case OF1X_AT_SET_QUEUE:
213 case OF1X_AT_SET_FIELD_ETH_DST:
217 case OF1X_AT_SET_FIELD_ETH_SRC:
221 case OF1X_AT_SET_FIELD_ETH_TYPE:
227 case OF1X_AT_SET_FIELD_VLAN_VID:
237 case OF1X_AT_SET_FIELD_VLAN_PCP:
249 case OF1X_AT_SET_FIELD_ARP_OPCODE:
253 case OF1X_AT_SET_FIELD_ARP_SHA:
257 case OF1X_AT_SET_FIELD_ARP_SPA:
261 case OF1X_AT_SET_FIELD_ARP_THA:
265 case OF1X_AT_SET_FIELD_ARP_TPA:
271 case OF1X_AT_SET_FIELD_NW_PROTO:
281 case OF1X_AT_SET_FIELD_NW_SRC:
290 case OF1X_AT_SET_FIELD_NW_DST:
301 case OF1X_AT_SET_FIELD_IP_DSCP:
305 case OF1X_AT_SET_FIELD_IP_ECN:
309 case OF1X_AT_SET_FIELD_IP_PROTO:
315 case OF1X_AT_SET_FIELD_IPV4_SRC:
319 case OF1X_AT_SET_FIELD_IPV4_DST:
325 case OF1X_AT_SET_FIELD_TP_SRC:
337 case OF1X_AT_SET_FIELD_TP_DST:
351 case OF1X_AT_SET_FIELD_TCP_SRC:
355 case OF1X_AT_SET_FIELD_TCP_DST:
361 case OF1X_AT_SET_FIELD_UDP_SRC:
365 case OF1X_AT_SET_FIELD_UDP_DST:
370 case OF1X_AT_SET_FIELD_SCTP_SRC:
374 case OF1X_AT_SET_FIELD_SCTP_DST:
381 case OF1X_AT_SET_FIELD_ICMPV4_TYPE:
385 case OF1X_AT_SET_FIELD_ICMPV4_CODE:
391 case OF1X_AT_SET_FIELD_MPLS_LABEL:
395 case OF1X_AT_SET_FIELD_MPLS_TC:
399 case OF1X_AT_SET_FIELD_MPLS_BOS:
406 case OF1X_AT_SET_FIELD_IPV6_SRC:
410 case OF1X_AT_SET_FIELD_IPV6_DST:
414 case OF1X_AT_SET_FIELD_IPV6_FLABEL:
418 case OF1X_AT_SET_FIELD_IPV6_ND_TARGET:
422 case OF1X_AT_SET_FIELD_IPV6_ND_SLL:
426 case OF1X_AT_SET_FIELD_IPV6_ND_TLL:
430 case OF1X_AT_SET_FIELD_IPV6_EXTHDR:
435 case OF1X_AT_SET_FIELD_ICMPV6_TYPE:
440 case OF1X_AT_SET_FIELD_ICMPV6_CODE:
445 #ifdef ROFL_EXPERIMENTAL
447 case OF1X_AT_POP_PPPOE:
449 platform_packet_pop_pppoe(pkt, action->__field.u16);
451 case OF1X_AT_PUSH_PPPOE:
453 platform_packet_push_pppoe(pkt, action->__field.u16);
457 case OF1X_AT_SET_FIELD_PPPOE_CODE:
459 platform_packet_set_pppoe_code(pkt, action->__field.u8);
461 case OF1X_AT_SET_FIELD_PPPOE_TYPE:
463 platform_packet_set_pppoe_type(pkt, action->__field.u8);
465 case OF1X_AT_SET_FIELD_PPPOE_SID:
467 platform_packet_set_pppoe_sid(pkt, action->__field.u16);
471 case OF1X_AT_SET_FIELD_PPP_PROT:
473 platform_packet_set_ppp_proto(pkt, action->__field.u16);
477 case OF1X_AT_SET_FIELD_GTP_MSG_TYPE:
479 platform_packet_set_gtp_msg_type(pkt, action->__field.u8);
481 case OF1X_AT_SET_FIELD_GTP_TEID:
483 platform_packet_set_gtp_teid(pkt, action->__field.u32);
485 case OF1X_AT_POP_GTP:
487 platform_packet_pop_gtp(pkt, action->__field.u16);
489 case OF1X_AT_PUSH_GTP:
491 platform_packet_push_gtp(pkt, action->__field.u16);
495 case OF1X_AT_SET_FIELD_CAPWAP_WBID:
497 platform_packet_set_capwap_wbid(pkt, action->__field.u8);
499 case OF1X_AT_SET_FIELD_CAPWAP_RID:
501 platform_packet_set_capwap_rid(pkt, action->__field.u8);
503 case OF1X_AT_SET_FIELD_CAPWAP_FLAGS:
505 platform_packet_set_capwap_flags(pkt, action->__field.u16);
507 case OF1X_AT_POP_CAPWAP:
509 platform_packet_pop_capwap(pkt);
511 case OF1X_AT_PUSH_CAPWAP:
513 platform_packet_push_capwap(pkt);
517 case OF1X_AT_SET_FIELD_WLAN_FC:
519 platform_packet_set_wlan_fc(pkt, action->__field.u16);
521 case OF1X_AT_SET_FIELD_WLAN_TYPE:
523 platform_packet_set_wlan_type(pkt, action->__field.u8);
525 case OF1X_AT_SET_FIELD_WLAN_SUBTYPE:
527 platform_packet_set_wlan_subtype(pkt, action->__field.u8);
529 case OF1X_AT_SET_FIELD_WLAN_DIRECTION:
531 platform_packet_set_wlan_direction(pkt, action->__field.u8);
533 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_1:
535 platform_packet_set_wlan_address_1(pkt, action->__field.u64);
537 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_2:
539 platform_packet_set_wlan_address_2(pkt, action->__field.u64);
541 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_3:
543 platform_packet_set_wlan_address_3(pkt, action->__field.u64);
545 case OF1X_AT_POP_WLAN:
547 platform_packet_pop_wlan(pkt);
549 case OF1X_AT_PUSH_WLAN:
551 platform_packet_push_wlan(pkt);
555 case OF1X_AT_SET_FIELD_GRE_VERSION:
557 platform_packet_set_gre_version(pkt, action->__field.u16);
559 case OF1X_AT_SET_FIELD_GRE_PROT_TYPE:
561 platform_packet_set_gre_prot_type(pkt, action->__field.u16);
563 case OF1X_AT_SET_FIELD_GRE_KEY:
565 platform_packet_set_gre_key(pkt, action->__field.u32);
567 case OF1X_AT_POP_GRE:
569 platform_packet_pop_gre(pkt, action->__field.u16);
571 case OF1X_AT_PUSH_GRE:
573 platform_packet_push_gre(pkt, action->__field.u16);
577 case OF1X_AT_POP_PPPOE:
578 case OF1X_AT_PUSH_PPPOE:
579 case OF1X_AT_SET_FIELD_PPPOE_CODE:
580 case OF1X_AT_SET_FIELD_PPPOE_TYPE:
581 case OF1X_AT_SET_FIELD_PPPOE_SID:
582 case OF1X_AT_SET_FIELD_PPP_PROT:
583 case OF1X_AT_SET_FIELD_GTP_MSG_TYPE:
584 case OF1X_AT_SET_FIELD_GTP_TEID:
585 case OF1X_AT_POP_GTP:
586 case OF1X_AT_PUSH_GTP:
587 case OF1X_AT_SET_FIELD_CAPWAP_WBID:
588 case OF1X_AT_SET_FIELD_CAPWAP_RID:
589 case OF1X_AT_SET_FIELD_CAPWAP_FLAGS:
590 case OF1X_AT_POP_CAPWAP:
591 case OF1X_AT_PUSH_CAPWAP:
592 case OF1X_AT_SET_FIELD_WLAN_FC:
593 case OF1X_AT_SET_FIELD_WLAN_TYPE:
594 case OF1X_AT_SET_FIELD_WLAN_SUBTYPE:
595 case OF1X_AT_SET_FIELD_WLAN_DIRECTION:
596 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_1:
597 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_2:
598 case OF1X_AT_SET_FIELD_WLAN_ADDRESS_3:
599 case OF1X_AT_POP_WLAN:
600 case OF1X_AT_PUSH_WLAN:
601 case OF1X_AT_SET_FIELD_GRE_VERSION:
602 case OF1X_AT_SET_FIELD_GRE_PROT_TYPE:
603 case OF1X_AT_SET_FIELD_GRE_KEY:
604 case OF1X_AT_POP_GRE:
605 case OF1X_AT_PUSH_GRE:
609 case OF1X_AT_SET_FIELD_PBB_ISID:
613 case OF1X_AT_POP_PBB:
617 case OF1X_AT_PUSH_PBB:
623 case OF1X_AT_SET_FIELD_TUNNEL_ID:
629 __of1x_process_group_actions(tid, sw, table_id, pkt, action->__field.u32, action->group, replicate_pkts);
632 case OF1X_AT_EXPERIMENTER:
638 port_id = action->__field.u32;
648 if(unlikely(pkt_to_send == NULL)){
649 ROFL_PIPELINE_INFO(
"Packet[%p] could NOT be cloned during OUTPUT action\n", pkt);
652 pkt_to_send->__cookie = pkt->__cookie;
653 ROFL_PIPELINE_INFO(
"Packet[%p] was cloned into [%p] during OUTPUT action\n", pkt, pkt_to_send);
659 if( port_id < LOGICAL_SWITCH_MAX_LOG_PORTS && unlikely(NULL != sw->logical_ports[port_id].port) ){
665 ROFL_PIPELINE_DEBUG(
"Packet[%p] dropped. Attempting to output to the incoming port %u\n", pkt_to_send, port_id);
671 ROFL_PIPELINE_INFO(
"Packet[%p] outputting to port num. %u\n", pkt_to_send, port_id);
675 }
else if(port_id == OF1X_PORT_FLOOD){
677 ROFL_PIPELINE_INFO(
"Packet[%p] outputting to FLOOD\n", pkt_to_send);
679 }
else if(port_id == OF1X_PORT_CONTROLLER ||
680 port_id == OF1X_PORT_NORMAL){
682 ROFL_PIPELINE_INFO(
"Packet[%p] outputting to CONTROLLER\n", pkt_to_send);
684 }
else if(port_id == OF1X_PORT_ALL){
686 ROFL_PIPELINE_INFO(
"Packet[%p] outputting to ALL_PORT\n", pkt_to_send);
688 }
else if(port_id == OF1X_PORT_IN_PORT){
690 ROFL_PIPELINE_INFO(
"Packet[%p] outputting to IN_PORT\n", pkt_to_send);
692 }
else if(port_id == OF1X_PORT_TABLE){
693 if(likely(reinject_pkt != NULL)){
695 ROFL_PIPELINE_INFO(
"Packet[%p] reinjecting pkt to the sw(%p) pipeline\n", sw, pkt_to_send);
696 *reinject_pkt = pkt_to_send;
697 assert(action->next == NULL);
700 ROFL_PIPELINE_INFO(
"ERROR: packet[%p->%p] trying to execute an output to meta-port 'TABLE' from a non-PKT_OUT action list.\n", pkt, pkt_to_send);
707 ROFL_PIPELINE_INFO(
"Packet[%p] WARNING output to UNKNOWN port %u. Dropping...\n", pkt_to_send, port_id);
723 for(it=apply_actions_group->head;it;it=it->next){
724 __of1x_process_packet_action(tid, sw, table_id, pkt, it, replicate_pkts, reinject_pkt);
732 static inline void __of1x_process_write_actions(
const unsigned int tid,
const struct of1x_switch* sw,
const unsigned int table_id,
datapacket_t* pkt,
bool replicate_pkts){
738 for(i=0,j=0;(i<write_actions->num_of_actions) && (j < OF1X_AT_NUMBER);j++){
741 __of1x_process_packet_action(tid, sw, table_id, pkt, &write_actions->actions[j], replicate_pkts, NULL);
750 #endif //OF1X_ACTION_PP
OpenFlow v1.0, 1.2 and 1.3.2 flow table abstraction.
Packet action abstraction data structure.
OpenFlow-enabled v1.0, 1.2 and 1.3.2 switch abstraction.
Group structure definition.
static void bitmap128_clean(bitmap128_t *bitmap)
Set bitmap to 0.
Statistics related to packet processing routines.
switch_port_t * all_meta_port
Special meta port: ALL.
static bool bitmap128_is_bit_set(const bitmap128_t *bitmap, unsigned int pos)
Check if bit is set in the 128bit bitmap.
OpenFlow v1.0, 1.2 and 1.3.2 actions.
Action group (apply-actions) structure.
void platform_of1x_packet_in(const of1x_switch_t *sw, uint8_t table_id, datapacket_t *pkt, uint16_t send_len, of_packet_in_reason_t reason)
Packet in event notification.
void dump_packet_matches(datapacket_t *const pkt, bool raw_nbo)
Dump the values of packet (header values)
switch_port_t * in_port_meta_port
Special meta port: IN_PORT.
OpenFlow v1.0, 1.2 and 1.3.2 group table subsystem.
switch_port_t * flood_meta_port
Special meta port: FLOOD.
static void bitmap128_set(bitmap128_t *bitmap, unsigned int pos)
Set a bit in the 128bit bitmap.