Commit 9a87c3fc authored by Dwip N. Banerjee's avatar Dwip N. Banerjee Committed by Jakub Kicinski

ibmvnic: Ensure that device queue memory is cache-line aligned

PCI bus slowdowns were observed on IBM VNIC devices as a result
of partial cache line writes and non-cache aligned full cache line writes.
Ensure that packet data buffers are cache-line aligned to avoid these
slowdowns.
Signed-off-by: default avatarDwip N. Banerjee <dnbanerg@us.ibm.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 8ed589f3
...@@ -498,7 +498,7 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter) ...@@ -498,7 +498,7 @@ static int reset_rx_pools(struct ibmvnic_adapter *adapter)
if (rx_pool->buff_size != buff_size) { if (rx_pool->buff_size != buff_size) {
free_long_term_buff(adapter, &rx_pool->long_term_buff); free_long_term_buff(adapter, &rx_pool->long_term_buff);
rx_pool->buff_size = buff_size; rx_pool->buff_size = ALIGN(buff_size, L1_CACHE_BYTES);
rc = alloc_long_term_buff(adapter, rc = alloc_long_term_buff(adapter,
&rx_pool->long_term_buff, &rx_pool->long_term_buff,
rx_pool->size * rx_pool->size *
...@@ -592,7 +592,7 @@ static int init_rx_pools(struct net_device *netdev) ...@@ -592,7 +592,7 @@ static int init_rx_pools(struct net_device *netdev)
rx_pool->size = adapter->req_rx_add_entries_per_subcrq; rx_pool->size = adapter->req_rx_add_entries_per_subcrq;
rx_pool->index = i; rx_pool->index = i;
rx_pool->buff_size = buff_size; rx_pool->buff_size = ALIGN(buff_size, L1_CACHE_BYTES);
rx_pool->active = 1; rx_pool->active = 1;
rx_pool->free_map = kcalloc(rx_pool->size, sizeof(int), rx_pool->free_map = kcalloc(rx_pool->size, sizeof(int),
...@@ -745,6 +745,7 @@ static int init_tx_pools(struct net_device *netdev) ...@@ -745,6 +745,7 @@ static int init_tx_pools(struct net_device *netdev)
{ {
struct ibmvnic_adapter *adapter = netdev_priv(netdev); struct ibmvnic_adapter *adapter = netdev_priv(netdev);
int tx_subcrqs; int tx_subcrqs;
u64 buff_size;
int i, rc; int i, rc;
tx_subcrqs = adapter->num_active_tx_scrqs; tx_subcrqs = adapter->num_active_tx_scrqs;
...@@ -761,9 +762,11 @@ static int init_tx_pools(struct net_device *netdev) ...@@ -761,9 +762,11 @@ static int init_tx_pools(struct net_device *netdev)
adapter->num_active_tx_pools = tx_subcrqs; adapter->num_active_tx_pools = tx_subcrqs;
for (i = 0; i < tx_subcrqs; i++) { for (i = 0; i < tx_subcrqs; i++) {
buff_size = adapter->req_mtu + VLAN_HLEN;
buff_size = ALIGN(buff_size, L1_CACHE_BYTES);
rc = init_one_tx_pool(netdev, &adapter->tx_pool[i], rc = init_one_tx_pool(netdev, &adapter->tx_pool[i],
adapter->req_tx_entries_per_subcrq, adapter->req_tx_entries_per_subcrq,
adapter->req_mtu + VLAN_HLEN); buff_size);
if (rc) { if (rc) {
release_tx_pools(adapter); release_tx_pools(adapter);
return rc; return rc;
......
...@@ -883,7 +883,7 @@ struct ibmvnic_sub_crq_queue { ...@@ -883,7 +883,7 @@ struct ibmvnic_sub_crq_queue {
atomic_t used; atomic_t used;
char name[32]; char name[32];
u64 handle; u64 handle;
}; } ____cacheline_aligned;
struct ibmvnic_long_term_buff { struct ibmvnic_long_term_buff {
unsigned char *buff; unsigned char *buff;
...@@ -907,7 +907,7 @@ struct ibmvnic_tx_pool { ...@@ -907,7 +907,7 @@ struct ibmvnic_tx_pool {
struct ibmvnic_long_term_buff long_term_buff; struct ibmvnic_long_term_buff long_term_buff;
int num_buffers; int num_buffers;
int buf_size; int buf_size;
}; } ____cacheline_aligned;
struct ibmvnic_rx_buff { struct ibmvnic_rx_buff {
struct sk_buff *skb; struct sk_buff *skb;
...@@ -928,7 +928,7 @@ struct ibmvnic_rx_pool { ...@@ -928,7 +928,7 @@ struct ibmvnic_rx_pool {
int next_alloc; int next_alloc;
int active; int active;
struct ibmvnic_long_term_buff long_term_buff; struct ibmvnic_long_term_buff long_term_buff;
}; } ____cacheline_aligned;
struct ibmvnic_vpd { struct ibmvnic_vpd {
unsigned char *buff; unsigned char *buff;
...@@ -1015,8 +1015,8 @@ struct ibmvnic_adapter { ...@@ -1015,8 +1015,8 @@ struct ibmvnic_adapter {
atomic_t running_cap_crqs; atomic_t running_cap_crqs;
bool wait_capability; bool wait_capability;
struct ibmvnic_sub_crq_queue **tx_scrq; struct ibmvnic_sub_crq_queue **tx_scrq ____cacheline_aligned;
struct ibmvnic_sub_crq_queue **rx_scrq; struct ibmvnic_sub_crq_queue **rx_scrq ____cacheline_aligned;
/* rx structs */ /* rx structs */
struct napi_struct *napi; struct napi_struct *napi;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment