@@ -919,6 +919,10 @@ static const struct nla_policy fq_policy[TCA_FQ_MAX + 1] = {
919
919
.type = NLA_BINARY ,
920
920
.len = sizeof (struct tc_prio_qopt ),
921
921
},
922
+ [TCA_FQ_WEIGHTS ] = {
923
+ .type = NLA_BINARY ,
924
+ .len = FQ_BANDS * sizeof (s32 ),
925
+ },
922
926
};
923
927
924
928
/* compress a u8 array with all elems <= 3 to an array of 2-bit fields */
@@ -941,6 +945,25 @@ static void fq_prio2band_decompress_crumb(const u8 *in, u8 *out)
941
945
out [i ] = fq_prio2band (in , i );
942
946
}
943
947
948
+ static int fq_load_weights (struct fq_sched_data * q ,
949
+ const struct nlattr * attr ,
950
+ struct netlink_ext_ack * extack )
951
+ {
952
+ s32 * weights = nla_data (attr );
953
+ int i ;
954
+
955
+ for (i = 0 ; i < FQ_BANDS ; i ++ ) {
956
+ if (weights [i ] < FQ_MIN_WEIGHT ) {
957
+ NL_SET_ERR_MSG_FMT_MOD (extack , "Weight %d less that minimum allowed %d" ,
958
+ weights [i ], FQ_MIN_WEIGHT );
959
+ return - EINVAL ;
960
+ }
961
+ }
962
+ for (i = 0 ; i < FQ_BANDS ; i ++ )
963
+ q -> band_flows [i ].quantum = weights [i ];
964
+ return 0 ;
965
+ }
966
+
944
967
static int fq_load_priomap (struct fq_sched_data * q ,
945
968
const struct nlattr * attr ,
946
969
struct netlink_ext_ack * extack )
@@ -1040,6 +1063,9 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt,
1040
1063
if (!err && tb [TCA_FQ_PRIOMAP ])
1041
1064
err = fq_load_priomap (q , tb [TCA_FQ_PRIOMAP ], extack );
1042
1065
1066
+ if (!err && tb [TCA_FQ_WEIGHTS ])
1067
+ err = fq_load_weights (q , tb [TCA_FQ_WEIGHTS ], extack );
1068
+
1043
1069
if (tb [TCA_FQ_ORPHAN_MASK ])
1044
1070
q -> orphan_mask = nla_get_u32 (tb [TCA_FQ_ORPHAN_MASK ]);
1045
1071
@@ -1142,6 +1168,7 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
1142
1168
};
1143
1169
u64 horizon = q -> horizon ;
1144
1170
struct nlattr * opts ;
1171
+ s32 weights [3 ];
1145
1172
1146
1173
opts = nla_nest_start_noflag (skb , TCA_OPTIONS );
1147
1174
if (opts == NULL )
@@ -1175,6 +1202,12 @@ static int fq_dump(struct Qdisc *sch, struct sk_buff *skb)
1175
1202
if (nla_put (skb , TCA_FQ_PRIOMAP , sizeof (prio ), & prio ))
1176
1203
goto nla_put_failure ;
1177
1204
1205
+ weights [0 ] = q -> band_flows [0 ].quantum ;
1206
+ weights [1 ] = q -> band_flows [1 ].quantum ;
1207
+ weights [2 ] = q -> band_flows [2 ].quantum ;
1208
+ if (nla_put (skb , TCA_FQ_WEIGHTS , sizeof (weights ), & weights ))
1209
+ goto nla_put_failure ;
1210
+
1178
1211
return nla_nest_end (skb , opts );
1179
1212
1180
1213
nla_put_failure :
0 commit comments