tc.c (83a187a4eb3a8d7b747e7cfd48228dbc4dbb5c92) tc.c (50f8f2f7fbf2f237a7938890f46c3edce0f51501)
1// SPDX-License-Identifier: GPL-2.0-only
2/****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2019 Solarflare Communications Inc.
5 * Copyright 2020-2022 Xilinx Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published

--- 581 unchanged lines hidden (view full) ---

590 /* Delete it from SW */
591 rhashtable_remove_fast(&efx->tc->match_action_ht, &rule->linkage,
592 efx_tc_match_action_ht_params);
593 netif_dbg(efx, drv, efx->net_dev, "Removed filter %lx\n", rule->cookie);
594 kfree(rule);
595 return 0;
596}
597
1// SPDX-License-Identifier: GPL-2.0-only
2/****************************************************************************
3 * Driver for Solarflare network controllers and boards
4 * Copyright 2019 Solarflare Communications Inc.
5 * Copyright 2020-2022 Xilinx Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published

--- 581 unchanged lines hidden (view full) ---

590 /* Delete it from SW */
591 rhashtable_remove_fast(&efx->tc->match_action_ht, &rule->linkage,
592 efx_tc_match_action_ht_params);
593 netif_dbg(efx, drv, efx->net_dev, "Removed filter %lx\n", rule->cookie);
594 kfree(rule);
595 return 0;
596}
597
598static int efx_tc_flower_stats(struct efx_nic *efx, struct net_device *net_dev,
599 struct flow_cls_offload *tc)
600{
601 struct netlink_ext_ack *extack = tc->common.extack;
602 struct efx_tc_counter_index *ctr;
603 struct efx_tc_counter *cnt;
604 u64 packets, bytes;
605
606 ctr = efx_tc_flower_find_counter_index(efx, tc->cookie);
607 if (!ctr) {
608 /* See comment in efx_tc_flower_destroy() */
609 if (!IS_ERR(efx_tc_flower_lookup_efv(efx, net_dev)))
610 if (net_ratelimit())
611 netif_warn(efx, drv, efx->net_dev,
612 "Filter %lx not found for stats\n",
613 tc->cookie);
614 NL_SET_ERR_MSG_MOD(extack, "Flow cookie not found in offloaded rules");
615 return -ENOENT;
616 }
617 if (WARN_ON(!ctr->cnt)) /* can't happen */
618 return -EIO;
619 cnt = ctr->cnt;
620
621 spin_lock_bh(&cnt->lock);
622 /* Report only new pkts/bytes since last time TC asked */
623 packets = cnt->packets;
624 bytes = cnt->bytes;
625 flow_stats_update(&tc->stats, bytes - cnt->old_bytes,
626 packets - cnt->old_packets, 0, cnt->touched,
627 FLOW_ACTION_HW_STATS_DELAYED);
628 cnt->old_packets = packets;
629 cnt->old_bytes = bytes;
630 spin_unlock_bh(&cnt->lock);
631 return 0;
632}
633
598int efx_tc_flower(struct efx_nic *efx, struct net_device *net_dev,
599 struct flow_cls_offload *tc, struct efx_rep *efv)
600{
601 int rc;
602
603 if (!efx->tc)
604 return -EOPNOTSUPP;
605
606 mutex_lock(&efx->tc->mutex);
607 switch (tc->command) {
608 case FLOW_CLS_REPLACE:
609 rc = efx_tc_flower_replace(efx, net_dev, tc, efv);
610 break;
611 case FLOW_CLS_DESTROY:
612 rc = efx_tc_flower_destroy(efx, net_dev, tc);
613 break;
634int efx_tc_flower(struct efx_nic *efx, struct net_device *net_dev,
635 struct flow_cls_offload *tc, struct efx_rep *efv)
636{
637 int rc;
638
639 if (!efx->tc)
640 return -EOPNOTSUPP;
641
642 mutex_lock(&efx->tc->mutex);
643 switch (tc->command) {
644 case FLOW_CLS_REPLACE:
645 rc = efx_tc_flower_replace(efx, net_dev, tc, efv);
646 break;
647 case FLOW_CLS_DESTROY:
648 rc = efx_tc_flower_destroy(efx, net_dev, tc);
649 break;
650 case FLOW_CLS_STATS:
651 rc = efx_tc_flower_stats(efx, net_dev, tc);
652 break;
614 default:
615 rc = -EOPNOTSUPP;
616 break;
617 }
618 mutex_unlock(&efx->tc->mutex);
619 return rc;
620}
621

--- 252 unchanged lines hidden ---
653 default:
654 rc = -EOPNOTSUPP;
655 break;
656 }
657 mutex_unlock(&efx->tc->mutex);
658 return rc;
659}
660

--- 252 unchanged lines hidden ---