Commit 1f233f32 authored by Vijaya Mohan Guvva's avatar Vijaya Mohan Guvva Committed by David S. Miller

liquidio: switchdev support for LiquidIO NIC

Enable switchdev for SRIOV capable LiquidIO NIC. It registers
a representor netdev (with switchdev_ops) for each SRIOV VF created.
It also has changes to send representor interface configurations like
admin state and MTU to LiquidIO firmware and to retrieve HW counted
VF stats for VF representor.
Signed-off-by: default avatarVijaya Mohan Guvva <vijaya.guvva@cavium.com>
Signed-off-by: default avatarSatanand Burla <satananda.burla@cavium.com>
Signed-off-by: default avatarRaghu Vatsavayi <raghu.vatsavayi@cavium.com>
Signed-off-by: default avatarFelix Manlunas <felix.manlunas@cavium.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2278f514
...@@ -17,7 +17,7 @@ liquidio-$(CONFIG_LIQUIDIO) += lio_ethtool.o \ ...@@ -17,7 +17,7 @@ liquidio-$(CONFIG_LIQUIDIO) += lio_ethtool.o \
octeon_droq.o \ octeon_droq.o \
octeon_nic.o octeon_nic.o
liquidio-objs := lio_main.o octeon_console.o $(liquidio-y) liquidio-objs := lio_main.o octeon_console.o lio_vf_rep.o $(liquidio-y)
obj-$(CONFIG_LIQUIDIO_VF) += liquidio_vf.o obj-$(CONFIG_LIQUIDIO_VF) += liquidio_vf.o
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/firmware.h> #include <linux/firmware.h>
#include <net/vxlan.h> #include <net/vxlan.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <net/switchdev.h>
#include "liquidio_common.h" #include "liquidio_common.h"
#include "octeon_droq.h" #include "octeon_droq.h"
#include "octeon_iq.h" #include "octeon_iq.h"
...@@ -3309,6 +3310,29 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx, ...@@ -3309,6 +3310,29 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx,
return 0; return 0;
} }
static int
lio_pf_switchdev_attr_get(struct net_device *dev, struct switchdev_attr *attr)
{
struct lio *lio = GET_LIO(dev);
switch (attr->id) {
case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
attr->u.ppid.id_len = ETH_ALEN;
ether_addr_copy(attr->u.ppid.id,
(void *)&lio->linfo.hw_addr + 2);
break;
default:
return -EOPNOTSUPP;
}
return 0;
}
static const struct switchdev_ops lio_pf_switchdev_ops = {
.switchdev_port_attr_get = lio_pf_switchdev_attr_get,
};
static const struct net_device_ops lionetdevops = { static const struct net_device_ops lionetdevops = {
.ndo_open = liquidio_open, .ndo_open = liquidio_open,
.ndo_stop = liquidio_stop, .ndo_stop = liquidio_stop,
...@@ -3583,6 +3607,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev) ...@@ -3583,6 +3607,7 @@ static int setup_nic_devices(struct octeon_device *octeon_dev)
* netdev tasks. * netdev tasks.
*/ */
netdev->netdev_ops = &lionetdevops; netdev->netdev_ops = &lionetdevops;
SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops);
lio = GET_LIO(netdev); lio = GET_LIO(netdev);
......
This diff is collapsed.
/**********************************************************************
* Author: Cavium, Inc.
*
* Contact: support@cavium.com
* Please include "LiquidIO" in the subject.
*
* Copyright (c) 2003-2017 Cavium, Inc.
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License, Version 2, as
* published by the Free Software Foundation.
*
* This file is distributed in the hope that it will be useful, but
* AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
* NONINFRINGEMENT. See the GNU General Public License for more
* details.
*
* This file may also be available under a different license from Cavium.
* Contact Cavium, Inc. for more information
**********************************************************************/
/*! \file octeon_vf_main.h
* \brief Host Driver: This file defines vf_rep related macros and structures
*/
#ifndef __LIO_VF_REP_H__
#define __LIO_VF_REP_H__
#define LIO_VF_REP_REQ_TMO_MS 5000
#define LIO_VF_REP_STATS_POLL_TIME_MS 200
struct lio_vf_rep_desc {
struct net_device *parent_ndev;
struct net_device *ndev;
struct octeon_device *oct;
struct lio_vf_rep_stats stats;
struct cavium_wk stats_wk;
atomic_t ifstate;
int ifidx;
};
struct lio_vf_rep_sc_ctx {
struct completion complete;
};
int lio_vf_rep_create(struct octeon_device *oct);
void lio_vf_rep_destroy(struct octeon_device *oct);
#endif
...@@ -89,6 +89,9 @@ enum octeon_tag_type { ...@@ -89,6 +89,9 @@ enum octeon_tag_type {
#define VF_DRV_REMOVED -1 #define VF_DRV_REMOVED -1
#define VF_DRV_MACADDR_CHANGED 2 #define VF_DRV_MACADDR_CHANGED 2
#define OPCODE_NIC_VF_REP_PKT 0x15
#define OPCODE_NIC_VF_REP_CMD 0x16
#define CORE_DRV_TEST_SCATTER_OP 0xFFF5 #define CORE_DRV_TEST_SCATTER_OP 0xFFF5
/* Application codes advertised by the core driver initialization packet. */ /* Application codes advertised by the core driver initialization packet. */
...@@ -909,4 +912,50 @@ struct lio_time { ...@@ -909,4 +912,50 @@ struct lio_time {
s64 sec; /* seconds */ s64 sec; /* seconds */
s64 nsec; /* nanoseconds */ s64 nsec; /* nanoseconds */
}; };
struct lio_vf_rep_stats {
u64 tx_packets;
u64 tx_bytes;
u64 tx_dropped;
u64 rx_packets;
u64 rx_bytes;
u64 rx_dropped;
};
enum lio_vf_rep_req_type {
LIO_VF_REP_REQ_NONE,
LIO_VF_REP_REQ_STATE,
LIO_VF_REP_REQ_MTU,
LIO_VF_REP_REQ_STATS
};
enum {
LIO_VF_REP_STATE_DOWN,
LIO_VF_REP_STATE_UP
};
struct lio_vf_rep_req {
u8 req_type;
u8 ifidx;
u8 rsvd[6];
union {
struct lio_vf_rep_mtu {
u32 mtu;
u32 rsvd;
} rep_mtu;
struct lio_vf_rep_state {
u8 state;
u8 rsvd[7];
} rep_state;
};
};
struct lio_vf_rep_resp {
u64 rh;
u8 status;
u8 rsvd[7];
};
#endif #endif
...@@ -391,6 +391,11 @@ struct octeon_ioq_vector { ...@@ -391,6 +391,11 @@ struct octeon_ioq_vector {
u32 ioq_num; u32 ioq_num;
}; };
struct lio_vf_rep_list {
int num_vfs;
struct net_device *ndev[CN23XX_MAX_VFS_PER_PF];
};
/** The Octeon device. /** The Octeon device.
* Each Octeon device has this structure to represent all its * Each Octeon device has this structure to represent all its
* components. * components.
...@@ -568,6 +573,8 @@ struct octeon_device { ...@@ -568,6 +573,8 @@ struct octeon_device {
atomic_t *adapter_fw_state; /* per-adapter, lio_fw_state */ atomic_t *adapter_fw_state; /* per-adapter, lio_fw_state */
bool ptp_enable; bool ptp_enable;
struct lio_vf_rep_list vf_rep_list;
}; };
#define OCT_DRV_ONLINE 1 #define OCT_DRV_ONLINE 1
......
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