All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Zhenning Xiao <zhenning.xiao@intel.com>,
	netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
	jogreene@redhat.com,
	Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 05/15] ice: Code optimization for ice_fill_sw_rule()
Date: Tue, 28 Aug 2018 12:04:03 -0700	[thread overview]
Message-ID: <20180828190413.29869-6-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20180828190413.29869-1-jeffrey.t.kirsher@intel.com>

From: Zhenning Xiao <zhenning.xiao@intel.com>

Use the buffer in the s_rule structure directly instead of using
a local array eth_hdr[DUMMY_ETH_HDR_LEN]

Signed-off-by: Zhenning Xiao <zhenning.xiao@intel.com>
Signed-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>
Tested-by: Tony Brelinski <tonyx.brelinski@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_switch.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c
index 6b7ec2ae5ad6..d8b18cabc3a8 100644
--- a/drivers/net/ethernet/intel/ice/ice_switch.c
+++ b/drivers/net/ethernet/intel/ice/ice_switch.c
@@ -464,8 +464,9 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
 		 struct ice_aqc_sw_rules_elem *s_rule, enum ice_adminq_opc opc)
 {
 	u16 vlan_id = ICE_MAX_VLAN_ID + 1;
-	u8 eth_hdr[DUMMY_ETH_HDR_LEN];
 	void *daddr = NULL;
+	u16 eth_hdr_sz;
+	u8 *eth_hdr;
 	u32 act = 0;
 	__be16 *off;
 
@@ -477,8 +478,11 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
 		return;
 	}
 
+	eth_hdr_sz = sizeof(dummy_eth_header);
+	eth_hdr = s_rule->pdata.lkup_tx_rx.hdr;
+
 	/* initialize the ether header with a dummy header */
-	memcpy(eth_hdr, dummy_eth_header, sizeof(dummy_eth_header));
+	memcpy(eth_hdr, dummy_eth_header, eth_hdr_sz);
 	ice_fill_sw_info(hw, f_info);
 
 	switch (f_info->fltr_act) {
@@ -536,7 +540,7 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
 		daddr = f_info->l_data.ethertype_mac.mac_addr;
 		/* fall-through */
 	case ICE_SW_LKUP_ETHERTYPE:
-		off = (__be16 *)&eth_hdr[ICE_ETH_ETHTYPE_OFFSET];
+		off = (__be16 *)(eth_hdr + ICE_ETH_ETHTYPE_OFFSET);
 		*off = cpu_to_be16(f_info->l_data.ethertype_mac.ethertype);
 		break;
 	case ICE_SW_LKUP_MAC_VLAN:
@@ -563,18 +567,16 @@ ice_fill_sw_rule(struct ice_hw *hw, struct ice_fltr_info *f_info,
 	s_rule->pdata.lkup_tx_rx.act = cpu_to_le32(act);
 
 	if (daddr)
-		ether_addr_copy(&eth_hdr[ICE_ETH_DA_OFFSET], daddr);
+		ether_addr_copy(eth_hdr + ICE_ETH_DA_OFFSET, daddr);
 
 	if (!(vlan_id > ICE_MAX_VLAN_ID)) {
-		off = (__be16 *)&eth_hdr[ICE_ETH_VLAN_TCI_OFFSET];
+		off = (__be16 *)(eth_hdr + ICE_ETH_VLAN_TCI_OFFSET);
 		*off = cpu_to_be16(vlan_id);
 	}
 
 	/* Create the switch rule with the final dummy Ethernet header */
 	if (opc != ice_aqc_opc_update_sw_rules)
-		s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(sizeof(eth_hdr));
-
-	memcpy(s_rule->pdata.lkup_tx_rx.hdr, eth_hdr, sizeof(eth_hdr));
+		s_rule->pdata.lkup_tx_rx.hdr_len = cpu_to_le16(eth_hdr_sz);
 }
 
 /**
-- 
2.17.1

  parent reply	other threads:[~2018-08-28 22:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-28 19:03 [net-next 00/15][pull request] 100GbE Intel Wired LAN Driver Updates 2018-08-28 Jeff Kirsher
2018-08-28 19:03 ` [net-next 01/15] ice: Rework flex descriptor programming Jeff Kirsher
2018-08-28 19:04 ` [net-next 02/15] ice: Updates to Tx scheduler code Jeff Kirsher
2018-08-28 19:04 ` [net-next 03/15] ice: Update request resource command to latest specification Jeff Kirsher
2018-08-28 19:04 ` [net-next 04/15] ice: Prevent control queue operations during reset Jeff Kirsher
2018-08-28 19:04 ` Jeff Kirsher [this message]
2018-08-28 19:04 ` [net-next 06/15] ice: Refactor switch rule management structures and functions Jeff Kirsher
2018-08-28 19:04 ` [net-next 07/15] ice: Refactor VSI allocation, deletion and rebuild flow Jeff Kirsher
2018-08-28 19:04 ` [net-next 08/15] ice: Implement handlers for ethtool PHY/link operations Jeff Kirsher
2018-08-28 19:04 ` [net-next 09/15] ice: Clean up register file Jeff Kirsher
2018-08-28 19:04 ` [net-next 10/15] ice: Add support for Tx hang, Tx timeout and malicious driver detection Jeff Kirsher
2018-08-28 19:04 ` [net-next 11/15] ice: Implement ice_bridge_getlink and ice_bridge_setlink Jeff Kirsher
2018-08-28 19:04 ` [net-next 12/15] ice: Enable firmware logging during device initialization Jeff Kirsher
2018-08-28 19:04 ` [net-next 13/15] ice: Enable VSI Rx/Tx pruning only when VLAN 0 is active Jeff Kirsher
2018-08-28 19:04 ` [net-next 14/15] ice: Introduce SERVICE_DIS flag and service routine functions Jeff Kirsher
2018-08-28 19:04 ` [net-next 15/15] ice: Fix and update driver version string Jeff Kirsher
2018-08-29  0:01 ` [net-next 00/15][pull request] 100GbE Intel Wired LAN Driver Updates 2018-08-28 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180828190413.29869-6-jeffrey.t.kirsher@intel.com \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=anirudh.venkataramanan@intel.com \
    --cc=davem@davemloft.net \
    --cc=jogreene@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@redhat.com \
    --cc=sassmann@redhat.com \
    --cc=zhenning.xiao@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.