Skip to content

Commit 7a91722

Browse files
Jiawen Wukuba-moo
authored andcommitted
net: txgbe: Support the FDIR rules assigned to VFs
When SR-IOV is enabled, the FDIR rule is supported to filter packets to VFs. The action queue id is calculated as an absolute id. Signed-off-by: Jiawen Wu <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 06ac077 commit 7a91722

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

drivers/net/ethernet/wangxun/txgbe/txgbe_ethtool.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,12 +367,19 @@ static int txgbe_add_ethtool_fdir_entry(struct txgbe *txgbe,
367367
queue = TXGBE_RDB_FDIR_DROP_QUEUE;
368368
} else {
369369
u32 ring = ethtool_get_flow_spec_ring(fsp->ring_cookie);
370+
u8 vf = ethtool_get_flow_spec_ring_vf(fsp->ring_cookie);
370371

371-
if (ring >= wx->num_rx_queues)
372+
if (!vf && ring >= wx->num_rx_queues)
373+
return -EINVAL;
374+
else if (vf && (vf > wx->num_vfs ||
375+
ring >= wx->num_rx_queues_per_pool))
372376
return -EINVAL;
373377

374378
/* Map the ring onto the absolute queue index */
375-
queue = wx->rx_ring[ring]->reg_idx;
379+
if (!vf)
380+
queue = wx->rx_ring[ring]->reg_idx;
381+
else
382+
queue = ((vf - 1) * wx->num_rx_queues_per_pool) + ring;
376383
}
377384

378385
/* Don't allow indexes to exist outside of available space */

drivers/net/ethernet/wangxun/txgbe/txgbe_fdir.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ void txgbe_atr(struct wx_ring *ring, struct wx_tx_buffer *first, u8 ptype)
307307
int txgbe_fdir_set_input_mask(struct wx *wx, union txgbe_atr_input *input_mask)
308308
{
309309
u32 fdirm = 0, fdirtcpm = 0, flex = 0;
310+
int index, offset;
310311

311312
/* Program the relevant mask registers. If src/dst_port or src/dst_addr
312313
* are zero, then assume a full mask for that field. Also assume that
@@ -352,23 +353,25 @@ int txgbe_fdir_set_input_mask(struct wx *wx, union txgbe_atr_input *input_mask)
352353
/* Now mask VM pool and destination IPv6 - bits 5 and 2 */
353354
wr32(wx, TXGBE_RDB_FDIR_OTHER_MSK, fdirm);
354355

355-
flex = rd32(wx, TXGBE_RDB_FDIR_FLEX_CFG(0));
356-
flex &= ~TXGBE_RDB_FDIR_FLEX_CFG_FIELD0;
356+
index = VMDQ_P(0) / 4;
357+
offset = VMDQ_P(0) % 4;
358+
flex = rd32(wx, TXGBE_RDB_FDIR_FLEX_CFG(index));
359+
flex &= ~(TXGBE_RDB_FDIR_FLEX_CFG_FIELD0 << (offset * 8));
357360
flex |= (TXGBE_RDB_FDIR_FLEX_CFG_BASE_MAC |
358-
TXGBE_RDB_FDIR_FLEX_CFG_OFST(0x6));
361+
TXGBE_RDB_FDIR_FLEX_CFG_OFST(0x6)) << (offset * 8);
359362

360363
switch ((__force u16)input_mask->formatted.flex_bytes & 0xFFFF) {
361364
case 0x0000:
362365
/* Mask Flex Bytes */
363-
flex |= TXGBE_RDB_FDIR_FLEX_CFG_MSK;
366+
flex |= TXGBE_RDB_FDIR_FLEX_CFG_MSK << (offset * 8);
364367
break;
365368
case 0xFFFF:
366369
break;
367370
default:
368371
wx_err(wx, "Error on flexible byte mask\n");
369372
return -EINVAL;
370373
}
371-
wr32(wx, TXGBE_RDB_FDIR_FLEX_CFG(0), flex);
374+
wr32(wx, TXGBE_RDB_FDIR_FLEX_CFG(index), flex);
372375

373376
/* store the TCP/UDP port masks, bit reversed from port layout */
374377
fdirtcpm = ntohs(input_mask->formatted.dst_port);
@@ -516,14 +519,16 @@ static void txgbe_fdir_enable(struct wx *wx, u32 fdirctrl)
516519
static void txgbe_init_fdir_signature(struct wx *wx)
517520
{
518521
u32 fdirctrl = TXGBE_FDIR_PBALLOC_64K;
522+
int index = VMDQ_P(0) / 4;
523+
int offset = VMDQ_P(0) % 4;
519524
u32 flex = 0;
520525

521-
flex = rd32(wx, TXGBE_RDB_FDIR_FLEX_CFG(0));
522-
flex &= ~TXGBE_RDB_FDIR_FLEX_CFG_FIELD0;
526+
flex = rd32(wx, TXGBE_RDB_FDIR_FLEX_CFG(index));
527+
flex &= ~(TXGBE_RDB_FDIR_FLEX_CFG_FIELD0 << (offset * 8));
523528

524529
flex |= (TXGBE_RDB_FDIR_FLEX_CFG_BASE_MAC |
525-
TXGBE_RDB_FDIR_FLEX_CFG_OFST(0x6));
526-
wr32(wx, TXGBE_RDB_FDIR_FLEX_CFG(0), flex);
530+
TXGBE_RDB_FDIR_FLEX_CFG_OFST(0x6)) << (offset * 8);
531+
wr32(wx, TXGBE_RDB_FDIR_FLEX_CFG(index), flex);
527532

528533
/* Continue setup of fdirctrl register bits:
529534
* Move the flexible bytes to use the ethertype - shift 6 words

drivers/net/ethernet/wangxun/txgbe/txgbe_type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ struct txgbe_fdir_filter {
287287
struct hlist_node fdir_node;
288288
union txgbe_atr_input filter;
289289
u16 sw_idx;
290-
u16 action;
290+
u64 action;
291291
};
292292

293293
/* TX/RX descriptor defines */

0 commit comments

Comments
 (0)