This is preparation for multi-queue (MQ) RX; nothing sets multi_queue yet, so single-queue behavior does not change. With MQ, PHYP (the PowerVM hypervisor) identifies each RX queue by a handle, and buffers are posted to a queue through it. On MQ firmware, H_REGISTER_LOGICAL_LAN also returns queue 0's handle, which ibmveth ignores today. Add a multi_queue flag and a queue_handle[] array. When multi_queue is set, register queue 0 with h_register_logical_lan_with_handle(), which makes the same hcall and saves the handle. Signed-off-by: Mingming Cao --- drivers/net/ethernet/ibm/ibmveth.c | 20 +++++++++++++-- drivers/net/ethernet/ibm/ibmveth.h | 40 ++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index 3a29fa601dba..236992ded33a 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c @@ -1192,6 +1192,7 @@ static long ibmveth_register_logical_lan(struct ibmveth_adapter *adapter, unsigned long ua = adapter->vdev->unit_address; unsigned long buf_dma = adapter->buffer_list_dma[0]; unsigned long filter_dma = adapter->filter_list_dma; + unsigned long qh0; /* * After a kexec the adapter will still be open, so our attempt to @@ -1199,8 +1200,23 @@ static long ibmveth_register_logical_lan(struct ibmveth_adapter *adapter, * try again, but only once. */ retry: - rc = h_register_logical_lan(ua, buf_dma, rxq_desc.desc, filter_dma, - mac_address); + /* In multi-queue mode, obtain a queue handle for queue 0 so all RX + * queues, even a single one, use the per-queue buffer hypercalls. + * multi_queue never changes after probe; PowerVM blocks LPM to a + * host without MQ support, so these hypercalls do not go away. + */ + if (adapter->multi_queue) { + rc = h_register_logical_lan_with_handle(ua, buf_dma, + rxq_desc.desc, + filter_dma, + mac_address, + &qh0); + if (rc == H_SUCCESS) + adapter->queue_handle[0] = qh0; + } else { + rc = h_register_logical_lan(ua, buf_dma, rxq_desc.desc, + filter_dma, mac_address); + } if (rc != H_SUCCESS && try_again) { rc = ibmveth_free_logical_lan(adapter); diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h index 03b087ed5761..7ac3372afc0f 100644 --- a/drivers/net/ethernet/ibm/ibmveth.h +++ b/drivers/net/ethernet/ibm/ibmveth.h @@ -68,6 +68,43 @@ static inline long h_add_logical_lan_buffers(unsigned long unit_address, desc5, desc6, desc7, desc8); } +/** + * h_register_logical_lan_with_handle - Register primary queue and get handle + * @unit_address: Device unit address + * @buffer_list: DMA address of buffer list + * @rec_queue: Buffer descriptor of receive queue + * @filter_list: DMA address of filter list + * @mac_address: MAC address + * @queue_handle: Output queue handle on success + * + * Like h_register_logical_lan(), but returns queue 0's handle so that + * multi-queue mode can post buffers to every queue by handle. R4 + * carries a handle only on firmware that reports MQ RX support in + * H_ILLAN_ATTRIBUTES. + * + * Return: hypervisor return code + */ +static inline long +h_register_logical_lan_with_handle(unsigned long unit_address, + unsigned long buffer_list, + unsigned long rec_queue, + unsigned long filter_list, + unsigned long mac_address, + unsigned long *queue_handle) +{ + unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; + long rc; + + rc = plpar_hcall(H_REGISTER_LOGICAL_LAN, retbuf, + unit_address, buffer_list, rec_queue, + filter_list, mac_address); + + if (rc == H_SUCCESS) + *queue_handle = retbuf[0]; + + return rc; +} + /* FW allows us to send 6 descriptors but we only use one so mark * the other 5 as unused (0) */ @@ -184,7 +221,10 @@ struct ibmveth_adapter { struct ibmveth_buff_pool rx_buff_pool[IBMVETH_MAX_RX_QUEUES][IBMVETH_NUM_BUFF_POOLS]; struct ibmveth_rx_q rx_queue[IBMVETH_MAX_RX_QUEUES]; + /* Opaque PHYP cookie, 0 can be valid. Set only in multi_queue mode. */ + u64 queue_handle[IBMVETH_MAX_RX_QUEUES]; unsigned int queue_irq[IBMVETH_MAX_RX_QUEUES]; + bool multi_queue; unsigned int num_rx_queues; int rx_csum; int large_send; -- 2.50.1 (Apple Git-155)