Commit 46899bde authored by Lijun Pan's avatar Lijun Pan Committed by David S. Miller

ibmvnic: create send_control_ip_offload

Factor send_control_ip_offload out of handle_query_ip_offload_rsp.
Signed-off-by: default avatarLijun Pan <ljp@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 16e811fe
......@@ -3981,6 +3981,85 @@ static void send_query_ip_offload(struct ibmvnic_adapter *adapter)
ibmvnic_send_crq(adapter, &crq);
}
static void send_control_ip_offload(struct ibmvnic_adapter *adapter)
{
struct ibmvnic_control_ip_offload_buffer *ctrl_buf = &adapter->ip_offload_ctrl;
struct ibmvnic_query_ip_offload_buffer *buf = &adapter->ip_offload_buf;
struct device *dev = &adapter->vdev->dev;
netdev_features_t old_hw_features = 0;
union ibmvnic_crq crq;
adapter->ip_offload_ctrl_tok =
dma_map_single(dev,
ctrl_buf,
sizeof(adapter->ip_offload_ctrl),
DMA_TO_DEVICE);
if (dma_mapping_error(dev, adapter->ip_offload_ctrl_tok)) {
dev_err(dev, "Couldn't map ip offload control buffer\n");
return;
}
ctrl_buf->len = cpu_to_be32(sizeof(adapter->ip_offload_ctrl));
ctrl_buf->version = cpu_to_be32(INITIAL_VERSION_IOB);
ctrl_buf->ipv4_chksum = buf->ipv4_chksum;
ctrl_buf->ipv6_chksum = buf->ipv6_chksum;
ctrl_buf->tcp_ipv4_chksum = buf->tcp_ipv4_chksum;
ctrl_buf->udp_ipv4_chksum = buf->udp_ipv4_chksum;
ctrl_buf->tcp_ipv6_chksum = buf->tcp_ipv6_chksum;
ctrl_buf->udp_ipv6_chksum = buf->udp_ipv6_chksum;
ctrl_buf->large_tx_ipv4 = buf->large_tx_ipv4;
ctrl_buf->large_tx_ipv6 = buf->large_tx_ipv6;
/* large_rx disabled for now, additional features needed */
ctrl_buf->large_rx_ipv4 = 0;
ctrl_buf->large_rx_ipv6 = 0;
if (adapter->state != VNIC_PROBING) {
old_hw_features = adapter->netdev->hw_features;
adapter->netdev->hw_features = 0;
}
adapter->netdev->hw_features = NETIF_F_SG | NETIF_F_GSO | NETIF_F_GRO;
if (buf->tcp_ipv4_chksum || buf->udp_ipv4_chksum)
adapter->netdev->hw_features |= NETIF_F_IP_CSUM;
if (buf->tcp_ipv6_chksum || buf->udp_ipv6_chksum)
adapter->netdev->hw_features |= NETIF_F_IPV6_CSUM;
if ((adapter->netdev->features &
(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))
adapter->netdev->hw_features |= NETIF_F_RXCSUM;
if (buf->large_tx_ipv4)
adapter->netdev->hw_features |= NETIF_F_TSO;
if (buf->large_tx_ipv6)
adapter->netdev->hw_features |= NETIF_F_TSO6;
if (adapter->state == VNIC_PROBING) {
adapter->netdev->features |= adapter->netdev->hw_features;
} else if (old_hw_features != adapter->netdev->hw_features) {
netdev_features_t tmp = 0;
/* disable features no longer supported */
adapter->netdev->features &= adapter->netdev->hw_features;
/* turn on features now supported if previously enabled */
tmp = (old_hw_features ^ adapter->netdev->hw_features) &
adapter->netdev->hw_features;
adapter->netdev->features |=
tmp & adapter->netdev->wanted_features;
}
memset(&crq, 0, sizeof(crq));
crq.control_ip_offload.first = IBMVNIC_CRQ_CMD;
crq.control_ip_offload.cmd = CONTROL_IP_OFFLOAD;
crq.control_ip_offload.len =
cpu_to_be32(sizeof(adapter->ip_offload_ctrl));
crq.control_ip_offload.ioba = cpu_to_be32(adapter->ip_offload_ctrl_tok);
ibmvnic_send_crq(adapter, &crq);
}
static void handle_vpd_size_rsp(union ibmvnic_crq *crq,
struct ibmvnic_adapter *adapter)
{
......@@ -4050,8 +4129,6 @@ static void handle_query_ip_offload_rsp(struct ibmvnic_adapter *adapter)
{
struct device *dev = &adapter->vdev->dev;
struct ibmvnic_query_ip_offload_buffer *buf = &adapter->ip_offload_buf;
netdev_features_t old_hw_features = 0;
union ibmvnic_crq crq;
int i;
dma_unmap_single(dev, adapter->ip_offload_tok,
......@@ -4101,74 +4178,7 @@ static void handle_query_ip_offload_rsp(struct ibmvnic_adapter *adapter)
netdev_dbg(adapter->netdev, "off_ipv6_ext_hd = %d\n",
buf->off_ipv6_ext_headers);
adapter->ip_offload_ctrl_tok =
dma_map_single(dev, &adapter->ip_offload_ctrl,
sizeof(adapter->ip_offload_ctrl), DMA_TO_DEVICE);
if (dma_mapping_error(dev, adapter->ip_offload_ctrl_tok)) {
dev_err(dev, "Couldn't map ip offload control buffer\n");
return;
}
adapter->ip_offload_ctrl.len =
cpu_to_be32(sizeof(adapter->ip_offload_ctrl));
adapter->ip_offload_ctrl.version = cpu_to_be32(INITIAL_VERSION_IOB);
adapter->ip_offload_ctrl.ipv4_chksum = buf->ipv4_chksum;
adapter->ip_offload_ctrl.ipv6_chksum = buf->ipv6_chksum;
adapter->ip_offload_ctrl.tcp_ipv4_chksum = buf->tcp_ipv4_chksum;
adapter->ip_offload_ctrl.udp_ipv4_chksum = buf->udp_ipv4_chksum;
adapter->ip_offload_ctrl.tcp_ipv6_chksum = buf->tcp_ipv6_chksum;
adapter->ip_offload_ctrl.udp_ipv6_chksum = buf->udp_ipv6_chksum;
adapter->ip_offload_ctrl.large_tx_ipv4 = buf->large_tx_ipv4;
adapter->ip_offload_ctrl.large_tx_ipv6 = buf->large_tx_ipv6;
/* large_rx disabled for now, additional features needed */
adapter->ip_offload_ctrl.large_rx_ipv4 = 0;
adapter->ip_offload_ctrl.large_rx_ipv6 = 0;
if (adapter->state != VNIC_PROBING) {
old_hw_features = adapter->netdev->hw_features;
adapter->netdev->hw_features = 0;
}
adapter->netdev->hw_features = NETIF_F_SG | NETIF_F_GSO | NETIF_F_GRO;
if (buf->tcp_ipv4_chksum || buf->udp_ipv4_chksum)
adapter->netdev->hw_features |= NETIF_F_IP_CSUM;
if (buf->tcp_ipv6_chksum || buf->udp_ipv6_chksum)
adapter->netdev->hw_features |= NETIF_F_IPV6_CSUM;
if ((adapter->netdev->features &
(NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM)))
adapter->netdev->hw_features |= NETIF_F_RXCSUM;
if (buf->large_tx_ipv4)
adapter->netdev->hw_features |= NETIF_F_TSO;
if (buf->large_tx_ipv6)
adapter->netdev->hw_features |= NETIF_F_TSO6;
if (adapter->state == VNIC_PROBING) {
adapter->netdev->features |= adapter->netdev->hw_features;
} else if (old_hw_features != adapter->netdev->hw_features) {
netdev_features_t tmp = 0;
/* disable features no longer supported */
adapter->netdev->features &= adapter->netdev->hw_features;
/* turn on features now supported if previously enabled */
tmp = (old_hw_features ^ adapter->netdev->hw_features) &
adapter->netdev->hw_features;
adapter->netdev->features |=
tmp & adapter->netdev->wanted_features;
}
memset(&crq, 0, sizeof(crq));
crq.control_ip_offload.first = IBMVNIC_CRQ_CMD;
crq.control_ip_offload.cmd = CONTROL_IP_OFFLOAD;
crq.control_ip_offload.len =
cpu_to_be32(sizeof(adapter->ip_offload_ctrl));
crq.control_ip_offload.ioba = cpu_to_be32(adapter->ip_offload_ctrl_tok);
ibmvnic_send_crq(adapter, &crq);
send_control_ip_offload(adapter);
}
static const char *ibmvnic_fw_err_cause(u16 cause)
......
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