@@ -509,7 +509,7 @@ static int
509
509
hws_definer_conv_outer (struct mlx5hws_definer_conv_data * cd ,
510
510
u32 * match_param )
511
511
{
512
- bool is_s_ipv6 , is_d_ipv6 , smac_set , dmac_set ;
512
+ bool is_ipv6 , smac_set , dmac_set , ip_addr_set , ip_ver_set ;
513
513
struct mlx5hws_definer_fc * fc = cd -> fc ;
514
514
struct mlx5hws_definer_fc * curr_fc ;
515
515
u32 * s_ipv6 , * d_ipv6 ;
@@ -521,6 +521,20 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
521
521
return - EINVAL ;
522
522
}
523
523
524
+ ip_addr_set = HWS_IS_FLD_SET_SZ (match_param ,
525
+ outer_headers .src_ipv4_src_ipv6 ,
526
+ 0x80 ) ||
527
+ HWS_IS_FLD_SET_SZ (match_param ,
528
+ outer_headers .dst_ipv4_dst_ipv6 , 0x80 );
529
+ ip_ver_set = HWS_IS_FLD_SET (match_param , outer_headers .ip_version ) ||
530
+ HWS_IS_FLD_SET (match_param , outer_headers .ethertype );
531
+
532
+ if (ip_addr_set && !ip_ver_set ) {
533
+ mlx5hws_err (cd -> ctx ,
534
+ "Unsupported match on IP address without version or ethertype\n" );
535
+ return - EINVAL ;
536
+ }
537
+
524
538
/* L2 Check ethertype */
525
539
HWS_SET_HDR (fc , match_param , ETH_TYPE_O ,
526
540
outer_headers .ethertype ,
@@ -570,10 +584,16 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
570
584
outer_headers .dst_ipv4_dst_ipv6 .ipv6_layout );
571
585
572
586
/* Assume IPv6 is used if ipv6 bits are set */
573
- is_s_ipv6 = s_ipv6 [0 ] || s_ipv6 [1 ] || s_ipv6 [2 ];
574
- is_d_ipv6 = d_ipv6 [0 ] || d_ipv6 [1 ] || d_ipv6 [2 ];
587
+ is_ipv6 = s_ipv6 [0 ] || s_ipv6 [1 ] || s_ipv6 [2 ] ||
588
+ d_ipv6 [0 ] || d_ipv6 [1 ] || d_ipv6 [2 ];
575
589
576
- if (is_s_ipv6 ) {
590
+ /* IHL is an IPv4-specific field. */
591
+ if (is_ipv6 && HWS_IS_FLD_SET (match_param , outer_headers .ipv4_ihl )) {
592
+ mlx5hws_err (cd -> ctx , "Unsupported match on IPv6 address and IPv4 IHL\n" );
593
+ return - EINVAL ;
594
+ }
595
+
596
+ if (is_ipv6 ) {
577
597
/* Handle IPv6 source address */
578
598
HWS_SET_HDR (fc , match_param , IPV6_SRC_127_96_O ,
579
599
outer_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_127_96 ,
@@ -587,13 +607,6 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
587
607
HWS_SET_HDR (fc , match_param , IPV6_SRC_31_0_O ,
588
608
outer_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
589
609
ipv6_src_outer .ipv6_address_31_0 );
590
- } else {
591
- /* Handle IPv4 source address */
592
- HWS_SET_HDR (fc , match_param , IPV4_SRC_O ,
593
- outer_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
594
- ipv4_src_dest_outer .source_address );
595
- }
596
- if (is_d_ipv6 ) {
597
610
/* Handle IPv6 destination address */
598
611
HWS_SET_HDR (fc , match_param , IPV6_DST_127_96_O ,
599
612
outer_headers .dst_ipv4_dst_ipv6 .ipv6_simple_layout .ipv6_127_96 ,
@@ -608,6 +621,10 @@ hws_definer_conv_outer(struct mlx5hws_definer_conv_data *cd,
608
621
outer_headers .dst_ipv4_dst_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
609
622
ipv6_dst_outer .ipv6_address_31_0 );
610
623
} else {
624
+ /* Handle IPv4 source address */
625
+ HWS_SET_HDR (fc , match_param , IPV4_SRC_O ,
626
+ outer_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
627
+ ipv4_src_dest_outer .source_address );
611
628
/* Handle IPv4 destination address */
612
629
HWS_SET_HDR (fc , match_param , IPV4_DST_O ,
613
630
outer_headers .dst_ipv4_dst_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
@@ -665,7 +682,7 @@ static int
665
682
hws_definer_conv_inner (struct mlx5hws_definer_conv_data * cd ,
666
683
u32 * match_param )
667
684
{
668
- bool is_s_ipv6 , is_d_ipv6 , smac_set , dmac_set ;
685
+ bool is_ipv6 , smac_set , dmac_set , ip_addr_set , ip_ver_set ;
669
686
struct mlx5hws_definer_fc * fc = cd -> fc ;
670
687
struct mlx5hws_definer_fc * curr_fc ;
671
688
u32 * s_ipv6 , * d_ipv6 ;
@@ -677,6 +694,20 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
677
694
return - EINVAL ;
678
695
}
679
696
697
+ ip_addr_set = HWS_IS_FLD_SET_SZ (match_param ,
698
+ inner_headers .src_ipv4_src_ipv6 ,
699
+ 0x80 ) ||
700
+ HWS_IS_FLD_SET_SZ (match_param ,
701
+ inner_headers .dst_ipv4_dst_ipv6 , 0x80 );
702
+ ip_ver_set = HWS_IS_FLD_SET (match_param , inner_headers .ip_version ) ||
703
+ HWS_IS_FLD_SET (match_param , inner_headers .ethertype );
704
+
705
+ if (ip_addr_set && !ip_ver_set ) {
706
+ mlx5hws_err (cd -> ctx ,
707
+ "Unsupported match on IP address without version or ethertype\n" );
708
+ return - EINVAL ;
709
+ }
710
+
680
711
/* L2 Check ethertype */
681
712
HWS_SET_HDR (fc , match_param , ETH_TYPE_I ,
682
713
inner_headers .ethertype ,
@@ -728,10 +759,16 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
728
759
inner_headers .dst_ipv4_dst_ipv6 .ipv6_layout );
729
760
730
761
/* Assume IPv6 is used if ipv6 bits are set */
731
- is_s_ipv6 = s_ipv6 [0 ] || s_ipv6 [1 ] || s_ipv6 [2 ];
732
- is_d_ipv6 = d_ipv6 [0 ] || d_ipv6 [1 ] || d_ipv6 [2 ];
762
+ is_ipv6 = s_ipv6 [0 ] || s_ipv6 [1 ] || s_ipv6 [2 ] ||
763
+ d_ipv6 [0 ] || d_ipv6 [1 ] || d_ipv6 [2 ];
733
764
734
- if (is_s_ipv6 ) {
765
+ /* IHL is an IPv4-specific field. */
766
+ if (is_ipv6 && HWS_IS_FLD_SET (match_param , inner_headers .ipv4_ihl )) {
767
+ mlx5hws_err (cd -> ctx , "Unsupported match on IPv6 address and IPv4 IHL\n" );
768
+ return - EINVAL ;
769
+ }
770
+
771
+ if (is_ipv6 ) {
735
772
/* Handle IPv6 source address */
736
773
HWS_SET_HDR (fc , match_param , IPV6_SRC_127_96_I ,
737
774
inner_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_127_96 ,
@@ -745,13 +782,6 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
745
782
HWS_SET_HDR (fc , match_param , IPV6_SRC_31_0_I ,
746
783
inner_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
747
784
ipv6_src_inner .ipv6_address_31_0 );
748
- } else {
749
- /* Handle IPv4 source address */
750
- HWS_SET_HDR (fc , match_param , IPV4_SRC_I ,
751
- inner_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
752
- ipv4_src_dest_inner .source_address );
753
- }
754
- if (is_d_ipv6 ) {
755
785
/* Handle IPv6 destination address */
756
786
HWS_SET_HDR (fc , match_param , IPV6_DST_127_96_I ,
757
787
inner_headers .dst_ipv4_dst_ipv6 .ipv6_simple_layout .ipv6_127_96 ,
@@ -766,6 +796,10 @@ hws_definer_conv_inner(struct mlx5hws_definer_conv_data *cd,
766
796
inner_headers .dst_ipv4_dst_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
767
797
ipv6_dst_inner .ipv6_address_31_0 );
768
798
} else {
799
+ /* Handle IPv4 source address */
800
+ HWS_SET_HDR (fc , match_param , IPV4_SRC_I ,
801
+ inner_headers .src_ipv4_src_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
802
+ ipv4_src_dest_inner .source_address );
769
803
/* Handle IPv4 destination address */
770
804
HWS_SET_HDR (fc , match_param , IPV4_DST_I ,
771
805
inner_headers .dst_ipv4_dst_ipv6 .ipv6_simple_layout .ipv6_31_0 ,
0 commit comments