Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e82b7c38 authored by Niranjana Vishwanathapura's avatar Niranjana Vishwanathapura Committed by Doug Ledford
Browse files

IB/opa_vnic: Properly set vesw port status



Update eth_link_status and operating status information to
represent the overall status of the virtual Ethernet switch port.

Reviewed-by: default avatarSudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: default avatarNiranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 4bbdfe25
Loading
Loading
Loading
Loading
+27 −12
Original line number Diff line number Diff line
@@ -112,6 +112,27 @@ static u16 opa_vnic_select_queue(struct net_device *netdev, struct sk_buff *skb,
	return rc;
}

static void opa_vnic_update_state(struct opa_vnic_adapter *adapter, bool up)
{
	struct __opa_veswport_info *info = &adapter->info;

	mutex_lock(&adapter->lock);
	/* Operational state can only be DROP_ALL or FORWARDING */
	if ((info->vport.config_state == OPA_VNIC_STATE_FORWARDING) && up) {
		info->vport.oper_state = OPA_VNIC_STATE_FORWARDING;
		info->vport.eth_link_status = OPA_VNIC_ETH_LINK_UP;
	} else {
		info->vport.oper_state = OPA_VNIC_STATE_DROP_ALL;
		info->vport.eth_link_status = OPA_VNIC_ETH_LINK_DOWN;
	}

	if (info->vport.config_state == OPA_VNIC_STATE_FORWARDING)
		netif_dormant_off(adapter->netdev);
	else
		netif_dormant_on(adapter->netdev);
	mutex_unlock(&adapter->lock);
}

/* opa_vnic_process_vema_config - process vema configuration updates */
void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter)
{
@@ -164,14 +185,8 @@ void opa_vnic_process_vema_config(struct opa_vnic_adapter *adapter)
		adapter->flow_tbl[i] = port_count ? port_num[i % port_count] :
						    OPA_VNIC_INVALID_PORT;

	/* Operational state can only be DROP_ALL or FORWARDING */
	if (info->vport.config_state == OPA_VNIC_STATE_FORWARDING) {
		info->vport.oper_state = OPA_VNIC_STATE_FORWARDING;
		netif_dormant_off(netdev);
	} else {
		info->vport.oper_state = OPA_VNIC_STATE_DROP_ALL;
		netif_dormant_on(netdev);
	}
	/* update state */
	opa_vnic_update_state(adapter, !!(netdev->flags & IFF_UP));
}

/*
@@ -269,8 +284,8 @@ static int opa_netdev_open(struct net_device *netdev)
		return rc;
	}

	/* Update eth link status and send trap */
	adapter->info.vport.eth_link_status = OPA_VNIC_ETH_LINK_UP;
	/* Update status and send trap */
	opa_vnic_update_state(adapter, true);
	opa_vnic_vema_report_event(adapter,
				   OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE);
	return 0;
@@ -288,8 +303,8 @@ static int opa_netdev_close(struct net_device *netdev)
		return rc;
	}

	/* Update eth link status and send trap */
	adapter->info.vport.eth_link_status = OPA_VNIC_ETH_LINK_DOWN;
	/* Update status and send trap */
	opa_vnic_update_state(adapter, false);
	opa_vnic_vema_report_event(adapter,
				   OPA_VESWPORT_TRAP_ETH_LINK_STATUS_CHANGE);
	return 0;