@@ -716,10 +716,11 @@ struct virtchnl_vlan_filter_list_v2 {
716
716
u16 vport_id ;
717
717
u16 num_elements ;
718
718
u8 pad [4 ];
719
- struct virtchnl_vlan_filter filters [1 ];
719
+ struct virtchnl_vlan_filter filters [];
720
720
};
721
721
722
- VIRTCHNL_CHECK_STRUCT_LEN (40 , virtchnl_vlan_filter_list_v2 );
722
+ VIRTCHNL_CHECK_STRUCT_LEN (8 , virtchnl_vlan_filter_list_v2 );
723
+ #define virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF 40
723
724
724
725
/* VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2
725
726
* VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2
@@ -918,10 +919,11 @@ VIRTCHNL_CHECK_STRUCT_LEN(16, virtchnl_channel_info);
918
919
struct virtchnl_tc_info {
919
920
u32 num_tc ;
920
921
u32 pad ;
921
- struct virtchnl_channel_info list [1 ];
922
+ struct virtchnl_channel_info list [];
922
923
};
923
924
924
- VIRTCHNL_CHECK_STRUCT_LEN (24 , virtchnl_tc_info );
925
+ VIRTCHNL_CHECK_STRUCT_LEN (8 , virtchnl_tc_info );
926
+ #define virtchnl_tc_info_LEGACY_SIZEOF 24
925
927
926
928
/* VIRTCHNL_ADD_CLOUD_FILTER
927
929
* VIRTCHNL_DEL_CLOUD_FILTER
@@ -1059,10 +1061,11 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_rdma_qv_info);
1059
1061
1060
1062
struct virtchnl_rdma_qvlist_info {
1061
1063
u32 num_vectors ;
1062
- struct virtchnl_rdma_qv_info qv_info [1 ];
1064
+ struct virtchnl_rdma_qv_info qv_info [];
1063
1065
};
1064
1066
1065
- VIRTCHNL_CHECK_STRUCT_LEN (16 , virtchnl_rdma_qvlist_info );
1067
+ VIRTCHNL_CHECK_STRUCT_LEN (4 , virtchnl_rdma_qvlist_info );
1068
+ #define virtchnl_rdma_qvlist_info_LEGACY_SIZEOF 16
1066
1069
1067
1070
/* VF reset states - these are written into the RSTAT register:
1068
1071
* VFGEN_RSTAT on the VF
@@ -1377,6 +1380,9 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1377
1380
#define __vss_byone (p , member , count , old ) \
1378
1381
(struct_size(p, member, count) + (old - 1 - struct_size(p, member, 0)))
1379
1382
1383
+ #define __vss_byelem (p , member , count , old ) \
1384
+ (struct_size(p, member, count - 1) + (old - struct_size(p, member, 0)))
1385
+
1380
1386
#define __vss_full (p , member , count , old ) \
1381
1387
(struct_size(p, member, count) + (old - struct_size(p, member, 0)))
1382
1388
@@ -1390,6 +1396,9 @@ VIRTCHNL_CHECK_STRUCT_LEN(12, virtchnl_fdir_del);
1390
1396
__vss(virtchnl_irq_map_info, __vss_full, p, m, c), \
1391
1397
__vss(virtchnl_ether_addr_list, __vss_full, p, m, c), \
1392
1398
__vss(virtchnl_vlan_filter_list, __vss_full, p, m, c), \
1399
+ __vss(virtchnl_vlan_filter_list_v2, __vss_byelem, p, m, c), \
1400
+ __vss(virtchnl_tc_info, __vss_byelem, p, m, c), \
1401
+ __vss(virtchnl_rdma_qvlist_info, __vss_byelem, p, m, c), \
1393
1402
__vss(virtchnl_rss_key, __vss_byone, p, m, c), \
1394
1403
__vss(virtchnl_rss_lut, __vss_byone, p, m, c))
1395
1404
@@ -1495,13 +1504,13 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1495
1504
case VIRTCHNL_OP_RELEASE_RDMA_IRQ_MAP :
1496
1505
break ;
1497
1506
case VIRTCHNL_OP_CONFIG_RDMA_IRQ_MAP :
1498
- valid_len = sizeof ( struct virtchnl_rdma_qvlist_info ) ;
1507
+ valid_len = virtchnl_rdma_qvlist_info_LEGACY_SIZEOF ;
1499
1508
if (msglen >= valid_len ) {
1500
1509
struct virtchnl_rdma_qvlist_info * qv =
1501
1510
(struct virtchnl_rdma_qvlist_info * )msg ;
1502
1511
1503
- valid_len += (( qv -> num_vectors - 1 ) *
1504
- sizeof ( struct virtchnl_rdma_qv_info ) );
1512
+ valid_len = virtchnl_struct_size ( qv , qv_info ,
1513
+ qv -> num_vectors );
1505
1514
}
1506
1515
break ;
1507
1516
case VIRTCHNL_OP_CONFIG_RSS_KEY :
@@ -1534,12 +1543,12 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1534
1543
valid_len = sizeof (struct virtchnl_vf_res_request );
1535
1544
break ;
1536
1545
case VIRTCHNL_OP_ENABLE_CHANNELS :
1537
- valid_len = sizeof ( struct virtchnl_tc_info ) ;
1546
+ valid_len = virtchnl_tc_info_LEGACY_SIZEOF ;
1538
1547
if (msglen >= valid_len ) {
1539
1548
struct virtchnl_tc_info * vti =
1540
1549
(struct virtchnl_tc_info * )msg ;
1541
- valid_len += (vti -> num_tc - 1 ) *
1542
- sizeof ( struct virtchnl_channel_info );
1550
+ valid_len = virtchnl_struct_size (vti , list ,
1551
+ vti -> num_tc );
1543
1552
if (vti -> num_tc == 0 )
1544
1553
err_msg_format = true;
1545
1554
}
@@ -1566,13 +1575,13 @@ virtchnl_vc_validate_vf_msg(struct virtchnl_version_info *ver, u32 v_opcode,
1566
1575
break ;
1567
1576
case VIRTCHNL_OP_ADD_VLAN_V2 :
1568
1577
case VIRTCHNL_OP_DEL_VLAN_V2 :
1569
- valid_len = sizeof ( struct virtchnl_vlan_filter_list_v2 ) ;
1578
+ valid_len = virtchnl_vlan_filter_list_v2_LEGACY_SIZEOF ;
1570
1579
if (msglen >= valid_len ) {
1571
1580
struct virtchnl_vlan_filter_list_v2 * vfl =
1572
1581
(struct virtchnl_vlan_filter_list_v2 * )msg ;
1573
1582
1574
- valid_len += (vfl -> num_elements - 1 ) *
1575
- sizeof ( struct virtchnl_vlan_filter );
1583
+ valid_len = virtchnl_struct_size (vfl , filters ,
1584
+ vfl -> num_elements );
1576
1585
1577
1586
if (vfl -> num_elements == 0 ) {
1578
1587
err_msg_format = true;
0 commit comments