@@ -2305,8 +2305,11 @@ static int dpaa_eth_poll(struct napi_struct *napi, int budget)
2305
2305
{
2306
2306
struct dpaa_napi_portal * np =
2307
2307
container_of (napi , struct dpaa_napi_portal , napi );
2308
+ int cleaned ;
2308
2309
2309
- int cleaned = qman_p_poll_dqrr (np -> p , budget );
2310
+ np -> xdp_act = 0 ;
2311
+
2312
+ cleaned = qman_p_poll_dqrr (np -> p , budget );
2310
2313
2311
2314
if (cleaned < budget ) {
2312
2315
napi_complete_done (napi , cleaned );
@@ -2315,6 +2318,9 @@ static int dpaa_eth_poll(struct napi_struct *napi, int budget)
2315
2318
qman_p_irqsource_add (np -> p , QM_PIRQ_DQRI );
2316
2319
}
2317
2320
2321
+ if (np -> xdp_act & XDP_REDIRECT )
2322
+ xdp_do_flush ();
2323
+
2318
2324
return cleaned ;
2319
2325
}
2320
2326
@@ -2457,6 +2463,7 @@ static u32 dpaa_run_xdp(struct dpaa_priv *priv, struct qm_fd *fd, void *vaddr,
2457
2463
struct xdp_frame * xdpf ;
2458
2464
struct xdp_buff xdp ;
2459
2465
u32 xdp_act ;
2466
+ int err ;
2460
2467
2461
2468
rcu_read_lock ();
2462
2469
@@ -2497,6 +2504,17 @@ static u32 dpaa_run_xdp(struct dpaa_priv *priv, struct qm_fd *fd, void *vaddr,
2497
2504
if (dpaa_xdp_xmit_frame (priv -> net_dev , xdpf ))
2498
2505
xdp_return_frame_rx_napi (xdpf );
2499
2506
2507
+ break ;
2508
+ case XDP_REDIRECT :
2509
+ /* Allow redirect to use the full headroom */
2510
+ xdp .data_hard_start = vaddr ;
2511
+ xdp .frame_sz = DPAA_BP_RAW_SIZE ;
2512
+
2513
+ err = xdp_do_redirect (priv -> net_dev , & xdp , xdp_prog );
2514
+ if (err ) {
2515
+ trace_xdp_exception (priv -> net_dev , xdp_prog , xdp_act );
2516
+ free_pages ((unsigned long )vaddr , 0 );
2517
+ }
2500
2518
break ;
2501
2519
default :
2502
2520
bpf_warn_invalid_xdp_action (xdp_act );
@@ -2527,6 +2545,7 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal,
2527
2545
struct dpaa_percpu_priv * percpu_priv ;
2528
2546
const struct qm_fd * fd = & dq -> fd ;
2529
2547
dma_addr_t addr = qm_fd_addr (fd );
2548
+ struct dpaa_napi_portal * np ;
2530
2549
enum qm_fd_format fd_format ;
2531
2550
struct net_device * net_dev ;
2532
2551
u32 fd_status , hash_offset ;
@@ -2541,6 +2560,7 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal,
2541
2560
u32 hash ;
2542
2561
u64 ns ;
2543
2562
2563
+ np = container_of (& portal , struct dpaa_napi_portal , p );
2544
2564
dpaa_fq = container_of (fq , struct dpaa_fq , fq_base );
2545
2565
fd_status = be32_to_cpu (fd -> status );
2546
2566
fd_format = qm_fd_get_format (fd );
@@ -2614,6 +2634,7 @@ static enum qman_cb_dqrr_result rx_default_dqrr(struct qman_portal *portal,
2614
2634
if (likely (fd_format == qm_fd_contig )) {
2615
2635
xdp_act = dpaa_run_xdp (priv , (struct qm_fd * )fd , vaddr ,
2616
2636
dpaa_fq , & xdp_meta_len );
2637
+ np -> xdp_act |= xdp_act ;
2617
2638
if (xdp_act != XDP_PASS ) {
2618
2639
percpu_stats -> rx_packets ++ ;
2619
2640
percpu_stats -> rx_bytes += qm_fd_get_length (fd );
@@ -2946,6 +2967,30 @@ static int dpaa_xdp(struct net_device *net_dev, struct netdev_bpf *xdp)
2946
2967
}
2947
2968
}
2948
2969
2970
+ static int dpaa_xdp_xmit (struct net_device * net_dev , int n ,
2971
+ struct xdp_frame * * frames , u32 flags )
2972
+ {
2973
+ struct xdp_frame * xdpf ;
2974
+ int i , err , drops = 0 ;
2975
+
2976
+ if (unlikely (flags & ~XDP_XMIT_FLAGS_MASK ))
2977
+ return - EINVAL ;
2978
+
2979
+ if (!netif_running (net_dev ))
2980
+ return - ENETDOWN ;
2981
+
2982
+ for (i = 0 ; i < n ; i ++ ) {
2983
+ xdpf = frames [i ];
2984
+ err = dpaa_xdp_xmit_frame (net_dev , xdpf );
2985
+ if (err ) {
2986
+ xdp_return_frame_rx_napi (xdpf );
2987
+ drops ++ ;
2988
+ }
2989
+ }
2990
+
2991
+ return n - drops ;
2992
+ }
2993
+
2949
2994
static int dpaa_ts_ioctl (struct net_device * dev , struct ifreq * rq , int cmd )
2950
2995
{
2951
2996
struct dpaa_priv * priv = netdev_priv (dev );
@@ -3014,6 +3059,7 @@ static const struct net_device_ops dpaa_ops = {
3014
3059
.ndo_setup_tc = dpaa_setup_tc ,
3015
3060
.ndo_change_mtu = dpaa_change_mtu ,
3016
3061
.ndo_bpf = dpaa_xdp ,
3062
+ .ndo_xdp_xmit = dpaa_xdp_xmit ,
3017
3063
};
3018
3064
3019
3065
static int dpaa_napi_add (struct net_device * net_dev )
0 commit comments