Merge branch 'ncsi'
Gavin Shan says: ==================== NCSI Support This series rebases on David's linux-net git repo ("master" branch). It's to support NCSI stack on drivers/net/ethernet/faraday/ftgmac100.c. The implementation is based on NCSI spec (version: 1.1.0): https://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.1.0.pdf As the following figure shows and defined in NCSI spec: * The NC-SI (aka NCSI) is defined as the interface between a (Base) Management Controller (BMC) and one or multiple Network Interface Controlers (NIC) on host side. The interface is responsible for providing external network connectivity for BMC. * Each BMC can connect to multiple packages, up to 8. Each package can have multiple channels, up to 32. Every package and channel are identified by 3-bits and 5-bits in NCSI packet. * NCSI packet, encapsulated in ethernet frame, has 0x88F8 in the protocol field. The destination MAC address should be 0xFF's while the source MAC address can be arbitrary one. * NCSI packets are classified to command, response, AEN (Asynchronous Event Notification). Commands are sent from BMC to host (NIC) for configuration and information retrival. Responses, corresponding to commands, are sent from host to BMC for confirmation and requested information. One command should have one and only one response. AEN is sent from host to BMC for notification (e.g. link down on active channel) so that BMC can take appropriate action. +------------------+ +----------------------------------------------+ | | | Host | | BMC | | | | | | +-------------------+ +-------------------+ | | +---------+ | | | Package-A | | Package-B | | | | | | | +---------+---------+ +-------------------+ | | |ftgmac100| | | | Channel | Channel | | Channel | Channel | | +----+----+----+---+ +-+---------+---------+--+---------+---------+-+ | | | | | | +-----------------------------+----------------------+ The series of patches is highlighted as: The design for the patchset is highlighted as below: * The network driver uses 3 interfaces exported from NCSI stack: ncsi_register_dev() - Register (create) a associated NCSI device. ncsi_start_dev() - Bring up the NCSI device. ncsi_unregister_dev() - Destroy the registered NCSI device. * There are several data structures introduced for different objects: struct ncsi_dev - NCSI device seen by network device driver. struct ncsi_dev_priv - NCSI device seen by NCSI stack. struct ncsi_package - NCSI package which can have multiple channels. struct ncsi_channel - NCSI channel. * The NCSI stack is driven by workqueue and state machine internally. * The all available NCSI packages and channels are enumerated (probed) on the first call to ncsi_start_dev(). The NCSI topology won't change until the NCSI device is destroyed. * All available channels will be brought up When the hardware arbitration is enabled. Otherwise, only one channel is selected as active one. The NCSI internal is driven by state machine with help of a workqueue. In the meanwhile, there are 3 states for each channel which can be put into a queue requesting for configuration or suspending. Channels in the queue with inactive state set will be configured (bringup) while channels in the queue with active state will be suspended (teardown). The request configuration or suspending is being applied on the channel if it's in invisible state. * Failover, another inactive channel is selected as active, can happen when the hardware arbitration is disabled. The failover can be caused by timeout on link monitor and AEN. * NCSI stack should be configurable through netlink or another mechanism, it's not implemented in this patchset. It's something TBD. * The first NIC driver that is aware of NCSI: drivers/net/ethernet/faraday/ftgmac100.c Changelog ========= v2 -> v3: * Include (one line) change in include/uapi/linux/if_ether.h to fix build error. v1 -> v2: * Support NCSI spec v1.1.0 (3 more commands and 4 hardware arbitration modes added). * Enable AEN packets according to the supported list. * Introduce NCSI channel states and processing queue in order to support the hardware arbitration. * The hardware arbitration is supported (tested with emulated environment). * Introduce link monitor with GLS (Get Link Status) command/response as part of the error handling defined in NCSI spec. * Support IPv6 address discovery when CONFIG_IPV6 is enabled. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
ddbcb79493
|
@ -31,6 +31,7 @@
|
|||
#include <linux/phy.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <net/ip.h>
|
||||
#include <net/ncsi.h>
|
||||
|
||||
#include "ftgmac100.h"
|
||||
|
||||
|
@ -68,10 +69,14 @@ struct ftgmac100 {
|
|||
|
||||
struct net_device *netdev;
|
||||
struct device *dev;
|
||||
struct ncsi_dev *ndev;
|
||||
struct napi_struct napi;
|
||||
|
||||
struct mii_bus *mii_bus;
|
||||
int old_speed;
|
||||
int int_mask_all;
|
||||
bool use_ncsi;
|
||||
bool enabled;
|
||||
};
|
||||
|
||||
static int ftgmac100_alloc_rx_page(struct ftgmac100 *priv,
|
||||
|
@ -80,14 +85,6 @@ static int ftgmac100_alloc_rx_page(struct ftgmac100 *priv,
|
|||
/******************************************************************************
|
||||
* internal functions (hardware register access)
|
||||
*****************************************************************************/
|
||||
#define INT_MASK_ALL_ENABLED (FTGMAC100_INT_RPKT_LOST | \
|
||||
FTGMAC100_INT_XPKT_ETH | \
|
||||
FTGMAC100_INT_XPKT_LOST | \
|
||||
FTGMAC100_INT_AHB_ERR | \
|
||||
FTGMAC100_INT_PHYSTS_CHG | \
|
||||
FTGMAC100_INT_RPKT_BUF | \
|
||||
FTGMAC100_INT_NO_RXBUF)
|
||||
|
||||
static void ftgmac100_set_rx_ring_base(struct ftgmac100 *priv, dma_addr_t addr)
|
||||
{
|
||||
iowrite32(addr, priv->base + FTGMAC100_OFFSET_RXR_BADR);
|
||||
|
@ -141,6 +138,64 @@ static void ftgmac100_set_mac(struct ftgmac100 *priv, const unsigned char *mac)
|
|||
iowrite32(laddr, priv->base + FTGMAC100_OFFSET_MAC_LADR);
|
||||
}
|
||||
|
||||
static void ftgmac100_setup_mac(struct ftgmac100 *priv)
|
||||
{
|
||||
u8 mac[ETH_ALEN];
|
||||
unsigned int m;
|
||||
unsigned int l;
|
||||
void *addr;
|
||||
|
||||
addr = device_get_mac_address(priv->dev, mac, ETH_ALEN);
|
||||
if (addr) {
|
||||
ether_addr_copy(priv->netdev->dev_addr, mac);
|
||||
dev_info(priv->dev, "Read MAC address %pM from device tree\n",
|
||||
mac);
|
||||
return;
|
||||
}
|
||||
|
||||
m = ioread32(priv->base + FTGMAC100_OFFSET_MAC_MADR);
|
||||
l = ioread32(priv->base + FTGMAC100_OFFSET_MAC_LADR);
|
||||
|
||||
mac[0] = (m >> 8) & 0xff;
|
||||
mac[1] = m & 0xff;
|
||||
mac[2] = (l >> 24) & 0xff;
|
||||
mac[3] = (l >> 16) & 0xff;
|
||||
mac[4] = (l >> 8) & 0xff;
|
||||
mac[5] = l & 0xff;
|
||||
|
||||
if (!is_valid_ether_addr(mac)) {
|
||||
mac[5] = (m >> 8) & 0xff;
|
||||
mac[4] = m & 0xff;
|
||||
mac[3] = (l >> 24) & 0xff;
|
||||
mac[2] = (l >> 16) & 0xff;
|
||||
mac[1] = (l >> 8) & 0xff;
|
||||
mac[0] = l & 0xff;
|
||||
}
|
||||
|
||||
if (is_valid_ether_addr(mac)) {
|
||||
ether_addr_copy(priv->netdev->dev_addr, mac);
|
||||
dev_info(priv->dev, "Read MAC address %pM from chip\n", mac);
|
||||
} else {
|
||||
eth_hw_addr_random(priv->netdev);
|
||||
dev_info(priv->dev, "Generated random MAC address %pM\n",
|
||||
priv->netdev->dev_addr);
|
||||
}
|
||||
}
|
||||
|
||||
static int ftgmac100_set_mac_addr(struct net_device *dev, void *p)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = eth_prepare_mac_addr_change(dev, p);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
eth_commit_mac_addr_change(dev, p);
|
||||
ftgmac100_set_mac(netdev_priv(dev), dev->dev_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ftgmac100_init_hw(struct ftgmac100 *priv)
|
||||
{
|
||||
/* setup ring buffer base registers */
|
||||
|
@ -952,7 +1007,10 @@ static irqreturn_t ftgmac100_interrupt(int irq, void *dev_id)
|
|||
struct net_device *netdev = dev_id;
|
||||
struct ftgmac100 *priv = netdev_priv(netdev);
|
||||
|
||||
if (likely(netif_running(netdev))) {
|
||||
/* When running in NCSI mode, the interface should be ready for
|
||||
* receiving or transmitting NCSI packets before it's opened.
|
||||
*/
|
||||
if (likely(priv->use_ncsi || netif_running(netdev))) {
|
||||
/* Disable interrupts for polling */
|
||||
iowrite32(0, priv->base + FTGMAC100_OFFSET_IER);
|
||||
napi_schedule(&priv->napi);
|
||||
|
@ -1005,8 +1063,9 @@ static int ftgmac100_poll(struct napi_struct *napi, int budget)
|
|||
ftgmac100_tx_complete(priv);
|
||||
}
|
||||
|
||||
if (status & (FTGMAC100_INT_NO_RXBUF | FTGMAC100_INT_RPKT_LOST |
|
||||
FTGMAC100_INT_AHB_ERR | FTGMAC100_INT_PHYSTS_CHG)) {
|
||||
if (status & priv->int_mask_all & (FTGMAC100_INT_NO_RXBUF |
|
||||
FTGMAC100_INT_RPKT_LOST | FTGMAC100_INT_AHB_ERR |
|
||||
FTGMAC100_INT_PHYSTS_CHG)) {
|
||||
if (net_ratelimit())
|
||||
netdev_info(netdev, "[ISR] = 0x%x: %s%s%s%s\n", status,
|
||||
status & FTGMAC100_INT_NO_RXBUF ? "NO_RXBUF " : "",
|
||||
|
@ -1029,7 +1088,8 @@ static int ftgmac100_poll(struct napi_struct *napi, int budget)
|
|||
napi_complete(napi);
|
||||
|
||||
/* enable all interrupts */
|
||||
iowrite32(INT_MASK_ALL_ENABLED, priv->base + FTGMAC100_OFFSET_IER);
|
||||
iowrite32(priv->int_mask_all,
|
||||
priv->base + FTGMAC100_OFFSET_IER);
|
||||
}
|
||||
|
||||
return rx;
|
||||
|
@ -1065,17 +1125,33 @@ static int ftgmac100_open(struct net_device *netdev)
|
|||
goto err_hw;
|
||||
|
||||
ftgmac100_init_hw(priv);
|
||||
ftgmac100_start_hw(priv, 10);
|
||||
|
||||
phy_start(netdev->phydev);
|
||||
ftgmac100_start_hw(priv, priv->use_ncsi ? 100 : 10);
|
||||
if (netdev->phydev)
|
||||
phy_start(netdev->phydev);
|
||||
else if (priv->use_ncsi)
|
||||
netif_carrier_on(netdev);
|
||||
|
||||
napi_enable(&priv->napi);
|
||||
netif_start_queue(netdev);
|
||||
|
||||
/* enable all interrupts */
|
||||
iowrite32(INT_MASK_ALL_ENABLED, priv->base + FTGMAC100_OFFSET_IER);
|
||||
iowrite32(priv->int_mask_all, priv->base + FTGMAC100_OFFSET_IER);
|
||||
|
||||
/* Start the NCSI device */
|
||||
if (priv->use_ncsi) {
|
||||
err = ncsi_start_dev(priv->ndev);
|
||||
if (err)
|
||||
goto err_ncsi;
|
||||
}
|
||||
|
||||
priv->enabled = true;
|
||||
|
||||
return 0;
|
||||
|
||||
err_ncsi:
|
||||
napi_disable(&priv->napi);
|
||||
netif_stop_queue(netdev);
|
||||
iowrite32(0, priv->base + FTGMAC100_OFFSET_IER);
|
||||
err_hw:
|
||||
free_irq(priv->irq, netdev);
|
||||
err_irq:
|
||||
|
@ -1088,12 +1164,17 @@ static int ftgmac100_stop(struct net_device *netdev)
|
|||
{
|
||||
struct ftgmac100 *priv = netdev_priv(netdev);
|
||||
|
||||
if (!priv->enabled)
|
||||
return 0;
|
||||
|
||||
/* disable all interrupts */
|
||||
priv->enabled = false;
|
||||
iowrite32(0, priv->base + FTGMAC100_OFFSET_IER);
|
||||
|
||||
netif_stop_queue(netdev);
|
||||
napi_disable(&priv->napi);
|
||||
phy_stop(netdev->phydev);
|
||||
if (netdev->phydev)
|
||||
phy_stop(netdev->phydev);
|
||||
|
||||
ftgmac100_stop_hw(priv);
|
||||
free_irq(priv->irq, netdev);
|
||||
|
@ -1134,6 +1215,9 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
|
|||
/* optional */
|
||||
static int ftgmac100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
|
||||
{
|
||||
if (!netdev->phydev)
|
||||
return -ENXIO;
|
||||
|
||||
return phy_mii_ioctl(netdev->phydev, ifr, cmd);
|
||||
}
|
||||
|
||||
|
@ -1141,11 +1225,74 @@ static const struct net_device_ops ftgmac100_netdev_ops = {
|
|||
.ndo_open = ftgmac100_open,
|
||||
.ndo_stop = ftgmac100_stop,
|
||||
.ndo_start_xmit = ftgmac100_hard_start_xmit,
|
||||
.ndo_set_mac_address = eth_mac_addr,
|
||||
.ndo_set_mac_address = ftgmac100_set_mac_addr,
|
||||
.ndo_validate_addr = eth_validate_addr,
|
||||
.ndo_do_ioctl = ftgmac100_do_ioctl,
|
||||
};
|
||||
|
||||
static int ftgmac100_setup_mdio(struct net_device *netdev)
|
||||
{
|
||||
struct ftgmac100 *priv = netdev_priv(netdev);
|
||||
struct platform_device *pdev = to_platform_device(priv->dev);
|
||||
int i, err = 0;
|
||||
|
||||
/* initialize mdio bus */
|
||||
priv->mii_bus = mdiobus_alloc();
|
||||
if (!priv->mii_bus)
|
||||
return -EIO;
|
||||
|
||||
priv->mii_bus->name = "ftgmac100_mdio";
|
||||
snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%d",
|
||||
pdev->name, pdev->id);
|
||||
priv->mii_bus->priv = priv->netdev;
|
||||
priv->mii_bus->read = ftgmac100_mdiobus_read;
|
||||
priv->mii_bus->write = ftgmac100_mdiobus_write;
|
||||
|
||||
for (i = 0; i < PHY_MAX_ADDR; i++)
|
||||
priv->mii_bus->irq[i] = PHY_POLL;
|
||||
|
||||
err = mdiobus_register(priv->mii_bus);
|
||||
if (err) {
|
||||
dev_err(priv->dev, "Cannot register MDIO bus!\n");
|
||||
goto err_register_mdiobus;
|
||||
}
|
||||
|
||||
err = ftgmac100_mii_probe(priv);
|
||||
if (err) {
|
||||
dev_err(priv->dev, "MII Probe failed!\n");
|
||||
goto err_mii_probe;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_mii_probe:
|
||||
mdiobus_unregister(priv->mii_bus);
|
||||
err_register_mdiobus:
|
||||
mdiobus_free(priv->mii_bus);
|
||||
return err;
|
||||
}
|
||||
|
||||
static void ftgmac100_destroy_mdio(struct net_device *netdev)
|
||||
{
|
||||
struct ftgmac100 *priv = netdev_priv(netdev);
|
||||
|
||||
if (!netdev->phydev)
|
||||
return;
|
||||
|
||||
phy_disconnect(netdev->phydev);
|
||||
mdiobus_unregister(priv->mii_bus);
|
||||
mdiobus_free(priv->mii_bus);
|
||||
}
|
||||
|
||||
static void ftgmac100_ncsi_handler(struct ncsi_dev *nd)
|
||||
{
|
||||
if (unlikely(nd->state != ncsi_dev_state_functional))
|
||||
return;
|
||||
|
||||
netdev_info(nd->dev, "NCSI interface %s\n",
|
||||
nd->link_up ? "up" : "down");
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* struct platform_driver functions
|
||||
*****************************************************************************/
|
||||
|
@ -1155,7 +1302,7 @@ static int ftgmac100_probe(struct platform_device *pdev)
|
|||
int irq;
|
||||
struct net_device *netdev;
|
||||
struct ftgmac100 *priv;
|
||||
int err;
|
||||
int err = 0;
|
||||
|
||||
if (!pdev)
|
||||
return -ENODEV;
|
||||
|
@ -1179,7 +1326,6 @@ static int ftgmac100_probe(struct platform_device *pdev)
|
|||
|
||||
netdev->ethtool_ops = &ftgmac100_ethtool_ops;
|
||||
netdev->netdev_ops = &ftgmac100_netdev_ops;
|
||||
netdev->features = NETIF_F_IP_CSUM | NETIF_F_GRO;
|
||||
|
||||
platform_set_drvdata(pdev, netdev);
|
||||
|
||||
|
@ -1211,31 +1357,45 @@ static int ftgmac100_probe(struct platform_device *pdev)
|
|||
|
||||
priv->irq = irq;
|
||||
|
||||
/* initialize mdio bus */
|
||||
priv->mii_bus = mdiobus_alloc();
|
||||
if (!priv->mii_bus) {
|
||||
err = -EIO;
|
||||
goto err_alloc_mdiobus;
|
||||
/* MAC address from chip or random one */
|
||||
ftgmac100_setup_mac(priv);
|
||||
|
||||
priv->int_mask_all = (FTGMAC100_INT_RPKT_LOST |
|
||||
FTGMAC100_INT_XPKT_ETH |
|
||||
FTGMAC100_INT_XPKT_LOST |
|
||||
FTGMAC100_INT_AHB_ERR |
|
||||
FTGMAC100_INT_PHYSTS_CHG |
|
||||
FTGMAC100_INT_RPKT_BUF |
|
||||
FTGMAC100_INT_NO_RXBUF);
|
||||
if (pdev->dev.of_node &&
|
||||
of_get_property(pdev->dev.of_node, "use-ncsi", NULL)) {
|
||||
if (!IS_ENABLED(CONFIG_NET_NCSI)) {
|
||||
dev_err(&pdev->dev, "NCSI stack not enabled\n");
|
||||
goto err_ncsi_dev;
|
||||
}
|
||||
|
||||
dev_info(&pdev->dev, "Using NCSI interface\n");
|
||||
priv->use_ncsi = true;
|
||||
priv->int_mask_all &= ~FTGMAC100_INT_PHYSTS_CHG;
|
||||
priv->ndev = ncsi_register_dev(netdev, ftgmac100_ncsi_handler);
|
||||
if (!priv->ndev)
|
||||
goto err_ncsi_dev;
|
||||
} else {
|
||||
priv->use_ncsi = false;
|
||||
err = ftgmac100_setup_mdio(netdev);
|
||||
if (err)
|
||||
goto err_setup_mdio;
|
||||
}
|
||||
|
||||
priv->mii_bus->name = "ftgmac100_mdio";
|
||||
snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "ftgmac100_mii");
|
||||
/* We have to disable on-chip IP checksum functionality
|
||||
* when NCSI is enabled on the interface. It doesn't work
|
||||
* in that case.
|
||||
*/
|
||||
netdev->features = NETIF_F_IP_CSUM | NETIF_F_GRO;
|
||||
if (priv->use_ncsi &&
|
||||
of_get_property(pdev->dev.of_node, "no-hw-checksum", NULL))
|
||||
netdev->features &= ~NETIF_F_IP_CSUM;
|
||||
|
||||
priv->mii_bus->priv = netdev;
|
||||
priv->mii_bus->read = ftgmac100_mdiobus_read;
|
||||
priv->mii_bus->write = ftgmac100_mdiobus_write;
|
||||
|
||||
err = mdiobus_register(priv->mii_bus);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "Cannot register MDIO bus!\n");
|
||||
goto err_register_mdiobus;
|
||||
}
|
||||
|
||||
err = ftgmac100_mii_probe(priv);
|
||||
if (err) {
|
||||
dev_err(&pdev->dev, "MII Probe failed!\n");
|
||||
goto err_mii_probe;
|
||||
}
|
||||
|
||||
/* register network device */
|
||||
err = register_netdev(netdev);
|
||||
|
@ -1246,21 +1406,12 @@ static int ftgmac100_probe(struct platform_device *pdev)
|
|||
|
||||
netdev_info(netdev, "irq %d, mapped at %p\n", priv->irq, priv->base);
|
||||
|
||||
if (!is_valid_ether_addr(netdev->dev_addr)) {
|
||||
eth_hw_addr_random(netdev);
|
||||
netdev_info(netdev, "generated random MAC address %pM\n",
|
||||
netdev->dev_addr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_ncsi_dev:
|
||||
err_register_netdev:
|
||||
phy_disconnect(netdev->phydev);
|
||||
err_mii_probe:
|
||||
mdiobus_unregister(priv->mii_bus);
|
||||
err_register_mdiobus:
|
||||
mdiobus_free(priv->mii_bus);
|
||||
err_alloc_mdiobus:
|
||||
ftgmac100_destroy_mdio(netdev);
|
||||
err_setup_mdio:
|
||||
iounmap(priv->base);
|
||||
err_ioremap:
|
||||
release_resource(priv->res);
|
||||
|
@ -1280,10 +1431,7 @@ static int __exit ftgmac100_remove(struct platform_device *pdev)
|
|||
priv = netdev_priv(netdev);
|
||||
|
||||
unregister_netdev(netdev);
|
||||
|
||||
phy_disconnect(netdev->phydev);
|
||||
mdiobus_unregister(priv->mii_bus);
|
||||
mdiobus_free(priv->mii_bus);
|
||||
ftgmac100_destroy_mdio(netdev);
|
||||
|
||||
iounmap(priv->base);
|
||||
release_resource(priv->res);
|
||||
|
@ -1293,14 +1441,20 @@ static int __exit ftgmac100_remove(struct platform_device *pdev)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id ftgmac100_of_match[] = {
|
||||
{ .compatible = "faraday,ftgmac100" },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, ftgmac100_of_match);
|
||||
|
||||
static struct platform_driver ftgmac100_driver = {
|
||||
.probe = ftgmac100_probe,
|
||||
.remove = __exit_p(ftgmac100_remove),
|
||||
.driver = {
|
||||
.name = DRV_NAME,
|
||||
.probe = ftgmac100_probe,
|
||||
.remove = __exit_p(ftgmac100_remove),
|
||||
.driver = {
|
||||
.name = DRV_NAME,
|
||||
.of_match_table = ftgmac100_of_match,
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(ftgmac100_driver);
|
||||
|
||||
MODULE_AUTHOR("Po-Yu Chuang <ratbert@faraday-tech.com>");
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef __NET_NCSI_H
|
||||
#define __NET_NCSI_H
|
||||
|
||||
/*
|
||||
* The NCSI device states seen from external. More NCSI device states are
|
||||
* only visible internally (in net/ncsi/internal.h). When the NCSI device
|
||||
* is registered, it's in ncsi_dev_state_registered state. The state
|
||||
* ncsi_dev_state_start is used to drive to choose active package and
|
||||
* channel. After that, its state is changed to ncsi_dev_state_functional.
|
||||
*
|
||||
* The state ncsi_dev_state_stop helps to shut down the currently active
|
||||
* package and channel while ncsi_dev_state_config helps to reconfigure
|
||||
* them.
|
||||
*/
|
||||
enum {
|
||||
ncsi_dev_state_registered = 0x0000,
|
||||
ncsi_dev_state_functional = 0x0100,
|
||||
ncsi_dev_state_probe = 0x0200,
|
||||
ncsi_dev_state_config = 0x0300,
|
||||
ncsi_dev_state_suspend = 0x0400,
|
||||
};
|
||||
|
||||
struct ncsi_dev {
|
||||
int state;
|
||||
int link_up;
|
||||
struct net_device *dev;
|
||||
void (*handler)(struct ncsi_dev *ndev);
|
||||
};
|
||||
|
||||
#ifdef CONFIG_NET_NCSI
|
||||
struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
|
||||
void (*notifier)(struct ncsi_dev *nd));
|
||||
int ncsi_start_dev(struct ncsi_dev *nd);
|
||||
void ncsi_unregister_dev(struct ncsi_dev *nd);
|
||||
#else /* !CONFIG_NET_NCSI */
|
||||
static inline struct ncsi_dev *ncsi_register_dev(struct net_device *dev,
|
||||
void (*notifier)(struct ncsi_dev *nd))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline int ncsi_start_dev(struct ncsi_dev *nd)
|
||||
{
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
static inline void ncsi_unregister_dev(struct ncsi_dev *nd)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_NET_NCSI */
|
||||
|
||||
#endif /* __NET_NCSI_H */
|
|
@ -87,6 +87,7 @@
|
|||
#define ETH_P_8021AH 0x88E7 /* 802.1ah Backbone Service Tag */
|
||||
#define ETH_P_MVRP 0x88F5 /* 802.1Q MVRP */
|
||||
#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */
|
||||
#define ETH_P_NCSI 0x88F8 /* NCSI protocol */
|
||||
#define ETH_P_PRP 0x88FB /* IEC 62439-3 PRP/HSRv0 */
|
||||
#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */
|
||||
#define ETH_P_TDLS 0x890D /* TDLS */
|
||||
|
|
|
@ -237,6 +237,7 @@ source "net/hsr/Kconfig"
|
|||
source "net/switchdev/Kconfig"
|
||||
source "net/l3mdev/Kconfig"
|
||||
source "net/qrtr/Kconfig"
|
||||
source "net/ncsi/Kconfig"
|
||||
|
||||
config RPS
|
||||
bool
|
||||
|
|
|
@ -79,3 +79,4 @@ ifneq ($(CONFIG_NET_L3_MASTER_DEV),)
|
|||
obj-y += l3mdev/
|
||||
endif
|
||||
obj-$(CONFIG_QRTR) += qrtr/
|
||||
obj-$(CONFIG_NET_NCSI) += ncsi/
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#
|
||||
# Configuration for NCSI support
|
||||
#
|
||||
|
||||
config NET_NCSI
|
||||
bool "NCSI interface support"
|
||||
depends on INET
|
||||
---help---
|
||||
This module provides NCSI (Network Controller Sideband Interface)
|
||||
support. Enable this only if your system connects to a network
|
||||
device via NCSI and the ethernet driver you're using supports
|
||||
the protocol explicitly.
|
|
@ -0,0 +1,4 @@
|
|||
#
|
||||
# Makefile for NCSI API
|
||||
#
|
||||
obj-$(CONFIG_NET_NCSI) += ncsi-cmd.o ncsi-rsp.o ncsi-aen.o ncsi-manage.o
|
|
@ -0,0 +1,328 @@
|
|||
/*
|
||||
* Copyright Gavin Shan, IBM Corporation 2016.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef __NCSI_INTERNAL_H__
|
||||
#define __NCSI_INTERNAL_H__
|
||||
|
||||
enum {
|
||||
NCSI_CAP_BASE = 0,
|
||||
NCSI_CAP_GENERIC = 0,
|
||||
NCSI_CAP_BC,
|
||||
NCSI_CAP_MC,
|
||||
NCSI_CAP_BUFFER,
|
||||
NCSI_CAP_AEN,
|
||||
NCSI_CAP_VLAN,
|
||||
NCSI_CAP_MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
NCSI_CAP_GENERIC_HWA = 0x01, /* HW arbitration */
|
||||
NCSI_CAP_GENERIC_HDS = 0x02, /* HNC driver status change */
|
||||
NCSI_CAP_GENERIC_FC = 0x04, /* HNC to MC flow control */
|
||||
NCSI_CAP_GENERIC_FC1 = 0x08, /* MC to HNC flow control */
|
||||
NCSI_CAP_GENERIC_MC = 0x10, /* Global MC filtering */
|
||||
NCSI_CAP_GENERIC_HWA_UNKNOWN = 0x00, /* Unknown HW arbitration */
|
||||
NCSI_CAP_GENERIC_HWA_SUPPORT = 0x20, /* Supported HW arbitration */
|
||||
NCSI_CAP_GENERIC_HWA_NOT_SUPPORT = 0x40, /* No HW arbitration */
|
||||
NCSI_CAP_GENERIC_HWA_RESERVED = 0x60, /* Reserved HW arbitration */
|
||||
NCSI_CAP_GENERIC_HWA_MASK = 0x60, /* Mask for HW arbitration */
|
||||
NCSI_CAP_GENERIC_MASK = 0x7f,
|
||||
NCSI_CAP_BC_ARP = 0x01, /* ARP packet filtering */
|
||||
NCSI_CAP_BC_DHCPC = 0x02, /* DHCP client filtering */
|
||||
NCSI_CAP_BC_DHCPS = 0x04, /* DHCP server filtering */
|
||||
NCSI_CAP_BC_NETBIOS = 0x08, /* NetBIOS packet filtering */
|
||||
NCSI_CAP_BC_MASK = 0x0f,
|
||||
NCSI_CAP_MC_IPV6_NEIGHBOR = 0x01, /* IPv6 neighbor filtering */
|
||||
NCSI_CAP_MC_IPV6_ROUTER = 0x02, /* IPv6 router filering */
|
||||
NCSI_CAP_MC_DHCPV6_RELAY = 0x04, /* DHCPv6 relay / server MC */
|
||||
NCSI_CAP_MC_DHCPV6_WELL_KNOWN = 0x08, /* DHCPv6 well-known MC */
|
||||
NCSI_CAP_MC_IPV6_MLD = 0x10, /* IPv6 MLD filtering */
|
||||
NCSI_CAP_MC_IPV6_NEIGHBOR_S = 0x20, /* IPv6 neighbour filtering */
|
||||
NCSI_CAP_MC_MASK = 0x3f,
|
||||
NCSI_CAP_AEN_LSC = 0x01, /* Link status change */
|
||||
NCSI_CAP_AEN_CR = 0x02, /* Configuration required */
|
||||
NCSI_CAP_AEN_HDS = 0x04, /* HNC driver status */
|
||||
NCSI_CAP_AEN_MASK = 0x07,
|
||||
NCSI_CAP_VLAN_ONLY = 0x01, /* Filter VLAN packet only */
|
||||
NCSI_CAP_VLAN_NO = 0x02, /* Filter VLAN and non-VLAN */
|
||||
NCSI_CAP_VLAN_ANY = 0x04, /* Filter Any-and-non-VLAN */
|
||||
NCSI_CAP_VLAN_MASK = 0x07
|
||||
};
|
||||
|
||||
enum {
|
||||
NCSI_MODE_BASE = 0,
|
||||
NCSI_MODE_ENABLE = 0,
|
||||
NCSI_MODE_TX_ENABLE,
|
||||
NCSI_MODE_LINK,
|
||||
NCSI_MODE_VLAN,
|
||||
NCSI_MODE_BC,
|
||||
NCSI_MODE_MC,
|
||||
NCSI_MODE_AEN,
|
||||
NCSI_MODE_FC,
|
||||
NCSI_MODE_MAX
|
||||
};
|
||||
|
||||
enum {
|
||||
NCSI_FILTER_BASE = 0,
|
||||
NCSI_FILTER_VLAN = 0,
|
||||
NCSI_FILTER_UC,
|
||||
NCSI_FILTER_MC,
|
||||
NCSI_FILTER_MIXED,
|
||||
NCSI_FILTER_MAX
|
||||
};
|
||||
|
||||
struct ncsi_channel_version {
|
||||
u32 version; /* Supported BCD encoded NCSI version */
|
||||
u32 alpha2; /* Supported BCD encoded NCSI version */
|
||||
u8 fw_name[12]; /* Firware name string */
|
||||
u32 fw_version; /* Firmware version */
|
||||
u16 pci_ids[4]; /* PCI identification */
|
||||
u32 mf_id; /* Manufacture ID */
|
||||
};
|
||||
|
||||
struct ncsi_channel_cap {
|
||||
u32 index; /* Index of channel capabilities */
|
||||
u32 cap; /* NCSI channel capability */
|
||||
};
|
||||
|
||||
struct ncsi_channel_mode {
|
||||
u32 index; /* Index of channel modes */
|
||||
u32 enable; /* Enabled or disabled */
|
||||
u32 size; /* Valid entries in ncm_data[] */
|
||||
u32 data[8]; /* Data entries */
|
||||
};
|
||||
|
||||
struct ncsi_channel_filter {
|
||||
u32 index; /* Index of channel filters */
|
||||
u32 total; /* Total entries in the filter table */
|
||||
u64 bitmap; /* Bitmap of valid entries */
|
||||
u32 data[]; /* Data for the valid entries */
|
||||
};
|
||||
|
||||
struct ncsi_channel_stats {
|
||||
u32 hnc_cnt_hi; /* Counter cleared */
|
||||
u32 hnc_cnt_lo; /* Counter cleared */
|
||||
u32 hnc_rx_bytes; /* Rx bytes */
|
||||
u32 hnc_tx_bytes; /* Tx bytes */
|
||||
u32 hnc_rx_uc_pkts; /* Rx UC packets */
|
||||
u32 hnc_rx_mc_pkts; /* Rx MC packets */
|
||||
u32 hnc_rx_bc_pkts; /* Rx BC packets */
|
||||
u32 hnc_tx_uc_pkts; /* Tx UC packets */
|
||||
u32 hnc_tx_mc_pkts; /* Tx MC packets */
|
||||
u32 hnc_tx_bc_pkts; /* Tx BC packets */
|
||||
u32 hnc_fcs_err; /* FCS errors */
|
||||
u32 hnc_align_err; /* Alignment errors */
|
||||
u32 hnc_false_carrier; /* False carrier detection */
|
||||
u32 hnc_runt_pkts; /* Rx runt packets */
|
||||
u32 hnc_jabber_pkts; /* Rx jabber packets */
|
||||
u32 hnc_rx_pause_xon; /* Rx pause XON frames */
|
||||
u32 hnc_rx_pause_xoff; /* Rx XOFF frames */
|
||||
u32 hnc_tx_pause_xon; /* Tx XON frames */
|
||||
u32 hnc_tx_pause_xoff; /* Tx XOFF frames */
|
||||
u32 hnc_tx_s_collision; /* Single collision frames */
|
||||
u32 hnc_tx_m_collision; /* Multiple collision frames */
|
||||
u32 hnc_l_collision; /* Late collision frames */
|
||||
u32 hnc_e_collision; /* Excessive collision frames */
|
||||
u32 hnc_rx_ctl_frames; /* Rx control frames */
|
||||
u32 hnc_rx_64_frames; /* Rx 64-bytes frames */
|
||||
u32 hnc_rx_127_frames; /* Rx 65-127 bytes frames */
|
||||
u32 hnc_rx_255_frames; /* Rx 128-255 bytes frames */
|
||||
u32 hnc_rx_511_frames; /* Rx 256-511 bytes frames */
|
||||
u32 hnc_rx_1023_frames; /* Rx 512-1023 bytes frames */
|
||||
u32 hnc_rx_1522_frames; /* Rx 1024-1522 bytes frames */
|
||||
u32 hnc_rx_9022_frames; /* Rx 1523-9022 bytes frames */
|
||||
u32 hnc_tx_64_frames; /* Tx 64-bytes frames */
|
||||
u32 hnc_tx_127_frames; /* Tx 65-127 bytes frames */
|
||||
u32 hnc_tx_255_frames; /* Tx 128-255 bytes frames */
|
||||
u32 hnc_tx_511_frames; /* Tx 256-511 bytes frames */
|
||||
u32 hnc_tx_1023_frames; /* Tx 512-1023 bytes frames */
|
||||
u32 hnc_tx_1522_frames; /* Tx 1024-1522 bytes frames */
|
||||
u32 hnc_tx_9022_frames; /* Tx 1523-9022 bytes frames */
|
||||
u32 hnc_rx_valid_bytes; /* Rx valid bytes */
|
||||
u32 hnc_rx_runt_pkts; /* Rx error runt packets */
|
||||
u32 hnc_rx_jabber_pkts; /* Rx error jabber packets */
|
||||
u32 ncsi_rx_cmds; /* Rx NCSI commands */
|
||||
u32 ncsi_dropped_cmds; /* Dropped commands */
|
||||
u32 ncsi_cmd_type_errs; /* Command type errors */
|
||||
u32 ncsi_cmd_csum_errs; /* Command checksum errors */
|
||||
u32 ncsi_rx_pkts; /* Rx NCSI packets */
|
||||
u32 ncsi_tx_pkts; /* Tx NCSI packets */
|
||||
u32 ncsi_tx_aen_pkts; /* Tx AEN packets */
|
||||
u32 pt_tx_pkts; /* Tx packets */
|
||||
u32 pt_tx_dropped; /* Tx dropped packets */
|
||||
u32 pt_tx_channel_err; /* Tx channel errors */
|
||||
u32 pt_tx_us_err; /* Tx undersize errors */
|
||||
u32 pt_rx_pkts; /* Rx packets */
|
||||
u32 pt_rx_dropped; /* Rx dropped packets */
|
||||
u32 pt_rx_channel_err; /* Rx channel errors */
|
||||
u32 pt_rx_us_err; /* Rx undersize errors */
|
||||
u32 pt_rx_os_err; /* Rx oversize errors */
|
||||
};
|
||||
|
||||
struct ncsi_dev_priv;
|
||||
struct ncsi_package;
|
||||
|
||||
#define NCSI_PACKAGE_SHIFT 5
|
||||
#define NCSI_PACKAGE_INDEX(c) (((c) >> NCSI_PACKAGE_SHIFT) & 0x7)
|
||||
#define NCSI_CHANNEL_INDEX(c) ((c) & ((1 << NCSI_PACKAGE_SHIFT) - 1))
|
||||
#define NCSI_TO_CHANNEL(p, c) (((p) << NCSI_PACKAGE_SHIFT) | (c))
|
||||
|
||||
struct ncsi_channel {
|
||||
unsigned char id;
|
||||
int state;
|
||||
#define NCSI_CHANNEL_INACTIVE 1
|
||||
#define NCSI_CHANNEL_ACTIVE 2
|
||||
#define NCSI_CHANNEL_INVISIBLE 3
|
||||
spinlock_t lock; /* Protect filters etc */
|
||||
struct ncsi_package *package;
|
||||
struct ncsi_channel_version version;
|
||||
struct ncsi_channel_cap caps[NCSI_CAP_MAX];
|
||||
struct ncsi_channel_mode modes[NCSI_MODE_MAX];
|
||||
struct ncsi_channel_filter *filters[NCSI_FILTER_MAX];
|
||||
struct ncsi_channel_stats stats;
|
||||
struct timer_list timer; /* Link monitor timer */
|
||||
bool enabled; /* Timer is enabled */
|
||||
unsigned int timeout; /* Times of timeout */
|
||||
struct list_head node;
|
||||
struct list_head link;
|
||||
};
|
||||
|
||||
struct ncsi_package {
|
||||
unsigned char id; /* NCSI 3-bits package ID */
|
||||
unsigned char uuid[16]; /* UUID */
|
||||
struct ncsi_dev_priv *ndp; /* NCSI device */
|
||||
spinlock_t lock; /* Protect the package */
|
||||
unsigned int channel_num; /* Number of channels */
|
||||
struct list_head channels; /* List of chanels */
|
||||
struct list_head node; /* Form list of packages */
|
||||
};
|
||||
|
||||
struct ncsi_request {
|
||||
unsigned char id; /* Request ID - 0 to 255 */
|
||||
bool used; /* Request that has been assigned */
|
||||
bool driven; /* Drive state machine */
|
||||
struct ncsi_dev_priv *ndp; /* Associated NCSI device */
|
||||
struct sk_buff *cmd; /* Associated NCSI command packet */
|
||||
struct sk_buff *rsp; /* Associated NCSI response packet */
|
||||
struct timer_list timer; /* Timer on waiting for response */
|
||||
bool enabled; /* Time has been enabled or not */
|
||||
};
|
||||
|
||||
enum {
|
||||
ncsi_dev_state_major = 0xff00,
|
||||
ncsi_dev_state_minor = 0x00ff,
|
||||
ncsi_dev_state_probe_deselect = 0x0201,
|
||||
ncsi_dev_state_probe_package,
|
||||
ncsi_dev_state_probe_channel,
|
||||
ncsi_dev_state_probe_cis,
|
||||
ncsi_dev_state_probe_gvi,
|
||||
ncsi_dev_state_probe_gc,
|
||||
ncsi_dev_state_probe_gls,
|
||||
ncsi_dev_state_probe_dp,
|
||||
ncsi_dev_state_config_sp = 0x0301,
|
||||
ncsi_dev_state_config_cis,
|
||||
ncsi_dev_state_config_sma,
|
||||
ncsi_dev_state_config_ebf,
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
ncsi_dev_state_config_egmf,
|
||||
#endif
|
||||
ncsi_dev_state_config_ecnt,
|
||||
ncsi_dev_state_config_ec,
|
||||
ncsi_dev_state_config_ae,
|
||||
ncsi_dev_state_config_gls,
|
||||
ncsi_dev_state_config_done,
|
||||
ncsi_dev_state_suspend_select = 0x0401,
|
||||
ncsi_dev_state_suspend_dcnt,
|
||||
ncsi_dev_state_suspend_dc,
|
||||
ncsi_dev_state_suspend_deselect,
|
||||
ncsi_dev_state_suspend_done
|
||||
};
|
||||
|
||||
struct ncsi_dev_priv {
|
||||
struct ncsi_dev ndev; /* Associated NCSI device */
|
||||
unsigned int flags; /* NCSI device flags */
|
||||
#define NCSI_DEV_PROBED 1 /* Finalized NCSI topology */
|
||||
#define NCSI_DEV_HWA 2 /* Enabled HW arbitration */
|
||||
#define NCSI_DEV_RESHUFFLE 4
|
||||
spinlock_t lock; /* Protect the NCSI device */
|
||||
#if IS_ENABLED(CONFIG_IPV6)
|
||||
unsigned int inet6_addr_num; /* Number of IPv6 addresses */
|
||||
#endif
|
||||
unsigned int package_num; /* Number of packages */
|
||||
struct list_head packages; /* List of packages */
|
||||
struct ncsi_request requests[256]; /* Request table */
|
||||
unsigned int request_id; /* Last used request ID */
|
||||
unsigned int pending_req_num; /* Number of pending requests */
|
||||
struct ncsi_package *active_package; /* Currently handled package */
|
||||
struct ncsi_channel *active_channel; /* Currently handled channel */
|
||||
struct list_head channel_queue; /* Config queue of channels */
|
||||
struct work_struct work; /* For channel management */
|
||||
struct packet_type ptype; /* NCSI packet Rx handler */
|
||||
struct list_head node; /* Form NCSI device list */
|
||||
};
|
||||
|
||||
struct ncsi_cmd_arg {
|
||||
struct ncsi_dev_priv *ndp; /* Associated NCSI device */
|
||||
unsigned char type; /* Command in the NCSI packet */
|
||||
unsigned char id; /* Request ID (sequence number) */
|
||||
unsigned char package; /* Destination package ID */
|
||||
unsigned char channel; /* Detination channel ID or 0x1f */
|
||||
unsigned short payload; /* Command packet payload length */
|
||||
bool driven; /* Drive the state machine? */
|
||||
union {
|
||||
unsigned char bytes[16]; /* Command packet specific data */
|
||||
unsigned short words[8];
|
||||
unsigned int dwords[4];
|
||||
};
|
||||
};
|
||||
|
||||
extern struct list_head ncsi_dev_list;
|
||||
extern spinlock_t ncsi_dev_lock;
|
||||
|
||||
#define TO_NCSI_DEV_PRIV(nd) \
|
||||
container_of(nd, struct ncsi_dev_priv, ndev)
|
||||
#define NCSI_FOR_EACH_DEV(ndp) \
|
||||
list_for_each_entry_rcu(ndp, &ncsi_dev_list, node)
|
||||
#define NCSI_FOR_EACH_PACKAGE(ndp, np) \
|
||||
list_for_each_entry_rcu(np, &ndp->packages, node)
|
||||
#define NCSI_FOR_EACH_CHANNEL(np, nc) \
|
||||
list_for_each_entry_rcu(nc, &np->channels, node)
|
||||
|
||||
/* Resources */
|
||||
int ncsi_find_filter(struct ncsi_channel *nc, int table, void *data);
|
||||
int ncsi_add_filter(struct ncsi_channel *nc, int table, void *data);
|
||||
int ncsi_remove_filter(struct ncsi_channel *nc, int table, int index);
|
||||
void ncsi_start_channel_monitor(struct ncsi_channel *nc);
|
||||
void ncsi_stop_channel_monitor(struct ncsi_channel *nc);
|
||||
struct ncsi_channel *ncsi_find_channel(struct ncsi_package *np,
|
||||
unsigned char id);
|
||||
struct ncsi_channel *ncsi_add_channel(struct ncsi_package *np,
|
||||
unsigned char id);
|
||||
struct ncsi_package *ncsi_find_package(struct ncsi_dev_priv *ndp,
|
||||
unsigned char id);
|
||||
struct ncsi_package *ncsi_add_package(struct ncsi_dev_priv *ndp,
|
||||
unsigned char id);
|
||||
void ncsi_remove_package(struct ncsi_package *np);
|
||||
void ncsi_find_package_and_channel(struct ncsi_dev_priv *ndp,
|
||||
unsigned char id,
|
||||
struct ncsi_package **np,
|
||||
struct ncsi_channel **nc);
|
||||
struct ncsi_request *ncsi_alloc_request(struct ncsi_dev_priv *ndp, bool driven);
|
||||
void ncsi_free_request(struct ncsi_request *nr);
|
||||
struct ncsi_dev *ncsi_find_dev(struct net_device *dev);
|
||||
int ncsi_process_next_channel(struct ncsi_dev_priv *ndp);
|
||||
|
||||
/* Packet handlers */
|
||||
u32 ncsi_calculate_checksum(unsigned char *data, int len);
|
||||
int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca);
|
||||
int ncsi_rcv_rsp(struct sk_buff *skb, struct net_device *dev,
|
||||
struct packet_type *pt, struct net_device *orig_dev);
|
||||
int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb);
|
||||
|
||||
#endif /* __NCSI_INTERNAL_H__ */
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* Copyright Gavin Shan, IBM Corporation 2016.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
#include <net/ncsi.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "ncsi-pkt.h"
|
||||
|
||||
static int ncsi_validate_aen_pkt(struct ncsi_aen_pkt_hdr *h,
|
||||
const unsigned short payload)
|
||||
{
|
||||
u32 checksum;
|
||||
__be32 *pchecksum;
|
||||
|
||||
if (h->common.revision != NCSI_PKT_REVISION)
|
||||
return -EINVAL;
|
||||
if (ntohs(h->common.length) != payload)
|
||||
return -EINVAL;
|
||||
|
||||
/* Validate checksum, which might be zeroes if the
|
||||
* sender doesn't support checksum according to NCSI
|
||||
* specification.
|
||||
*/
|
||||
pchecksum = (__be32 *)((void *)(h + 1) + payload - 4);
|
||||
if (ntohl(*pchecksum) == 0)
|
||||
return 0;
|
||||
|
||||
checksum = ncsi_calculate_checksum((unsigned char *)h,
|
||||
sizeof(*h) + payload - 4);
|
||||
if (*pchecksum != htonl(checksum))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_aen_handler_lsc(struct ncsi_dev_priv *ndp,
|
||||
struct ncsi_aen_pkt_hdr *h)
|
||||
{
|
||||
struct ncsi_aen_lsc_pkt *lsc;
|
||||
struct ncsi_channel *nc;
|
||||
struct ncsi_channel_mode *ncm;
|
||||
unsigned long old_data;
|
||||
unsigned long flags;
|
||||
|
||||
/* Find the NCSI channel */
|
||||
ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc);
|
||||
if (!nc)
|
||||
return -ENODEV;
|
||||
|
||||
/* Update the link status */
|
||||
ncm = &nc->modes[NCSI_MODE_LINK];
|
||||
lsc = (struct ncsi_aen_lsc_pkt *)h;
|
||||
old_data = ncm->data[2];
|
||||
ncm->data[2] = ntohl(lsc->status);
|
||||
ncm->data[4] = ntohl(lsc->oem_status);
|
||||
if (!((old_data ^ ncm->data[2]) & 0x1) ||
|
||||
!list_empty(&nc->link))
|
||||
return 0;
|
||||
if (!(nc->state == NCSI_CHANNEL_INACTIVE && (ncm->data[2] & 0x1)) &&
|
||||
!(nc->state == NCSI_CHANNEL_ACTIVE && !(ncm->data[2] & 0x1)))
|
||||
return 0;
|
||||
|
||||
if (!(ndp->flags & NCSI_DEV_HWA) &&
|
||||
nc->state == NCSI_CHANNEL_ACTIVE)
|
||||
ndp->flags |= NCSI_DEV_RESHUFFLE;
|
||||
|
||||
ncsi_stop_channel_monitor(nc);
|
||||
spin_lock_irqsave(&ndp->lock, flags);
|
||||
list_add_tail_rcu(&nc->link, &ndp->channel_queue);
|
||||
spin_unlock_irqrestore(&ndp->lock, flags);
|
||||
|
||||
return ncsi_process_next_channel(ndp);
|
||||
}
|
||||
|
||||
static int ncsi_aen_handler_cr(struct ncsi_dev_priv *ndp,
|
||||
struct ncsi_aen_pkt_hdr *h)
|
||||
{
|
||||
struct ncsi_channel *nc;
|
||||
unsigned long flags;
|
||||
|
||||
/* Find the NCSI channel */
|
||||
ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc);
|
||||
if (!nc)
|
||||
return -ENODEV;
|
||||
|
||||
if (!list_empty(&nc->link) ||
|
||||
nc->state != NCSI_CHANNEL_ACTIVE)
|
||||
return 0;
|
||||
|
||||
ncsi_stop_channel_monitor(nc);
|
||||
spin_lock_irqsave(&ndp->lock, flags);
|
||||
xchg(&nc->state, NCSI_CHANNEL_INACTIVE);
|
||||
list_add_tail_rcu(&nc->link, &ndp->channel_queue);
|
||||
spin_unlock_irqrestore(&ndp->lock, flags);
|
||||
|
||||
return ncsi_process_next_channel(ndp);
|
||||
}
|
||||
|
||||
static int ncsi_aen_handler_hncdsc(struct ncsi_dev_priv *ndp,
|
||||
struct ncsi_aen_pkt_hdr *h)
|
||||
{
|
||||
struct ncsi_channel *nc;
|
||||
struct ncsi_channel_mode *ncm;
|
||||
struct ncsi_aen_hncdsc_pkt *hncdsc;
|
||||
unsigned long flags;
|
||||
|
||||
/* Find the NCSI channel */
|
||||
ncsi_find_package_and_channel(ndp, h->common.channel, NULL, &nc);
|
||||
if (!nc)
|
||||
return -ENODEV;
|
||||
|
||||
/* If the channel is active one, we need reconfigure it */
|
||||
ncm = &nc->modes[NCSI_MODE_LINK];
|
||||
hncdsc = (struct ncsi_aen_hncdsc_pkt *)h;
|
||||
ncm->data[3] = ntohl(hncdsc->status);
|
||||
if (!list_empty(&nc->link) ||
|
||||
nc->state != NCSI_CHANNEL_ACTIVE ||
|
||||
(ncm->data[3] & 0x1))
|
||||
return 0;
|
||||
|
||||
if (ndp->flags & NCSI_DEV_HWA)
|
||||
ndp->flags |= NCSI_DEV_RESHUFFLE;
|
||||
|
||||
/* If this channel is the active one and the link doesn't
|
||||
* work, we have to choose another channel to be active one.
|
||||
* The logic here is exactly similar to what we do when link
|
||||
* is down on the active channel.
|
||||
*/
|
||||
ncsi_stop_channel_monitor(nc);
|
||||
spin_lock_irqsave(&ndp->lock, flags);
|
||||
list_add_tail_rcu(&nc->link, &ndp->channel_queue);
|
||||
spin_unlock_irqrestore(&ndp->lock, flags);
|
||||
|
||||
ncsi_process_next_channel(ndp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ncsi_aen_handler {
|
||||
unsigned char type;
|
||||
int payload;
|
||||
int (*handler)(struct ncsi_dev_priv *ndp,
|
||||
struct ncsi_aen_pkt_hdr *h);
|
||||
} ncsi_aen_handlers[] = {
|
||||
{ NCSI_PKT_AEN_LSC, 12, ncsi_aen_handler_lsc },
|
||||
{ NCSI_PKT_AEN_CR, 4, ncsi_aen_handler_cr },
|
||||
{ NCSI_PKT_AEN_HNCDSC, 4, ncsi_aen_handler_hncdsc }
|
||||
};
|
||||
|
||||
int ncsi_aen_handler(struct ncsi_dev_priv *ndp, struct sk_buff *skb)
|
||||
{
|
||||
struct ncsi_aen_pkt_hdr *h;
|
||||
struct ncsi_aen_handler *nah = NULL;
|
||||
int i, ret;
|
||||
|
||||
/* Find the handler */
|
||||
h = (struct ncsi_aen_pkt_hdr *)skb_network_header(skb);
|
||||
for (i = 0; i < ARRAY_SIZE(ncsi_aen_handlers); i++) {
|
||||
if (ncsi_aen_handlers[i].type == h->type) {
|
||||
nah = &ncsi_aen_handlers[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nah) {
|
||||
netdev_warn(ndp->ndev.dev, "Invalid AEN (0x%x) received\n",
|
||||
h->type);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
ret = ncsi_validate_aen_pkt(h, nah->payload);
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = nah->handler(ndp, h);
|
||||
out:
|
||||
consume_skb(skb);
|
||||
return ret;
|
||||
}
|
|
@ -0,0 +1,367 @@
|
|||
/*
|
||||
* Copyright Gavin Shan, IBM Corporation 2016.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/etherdevice.h>
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/skbuff.h>
|
||||
|
||||
#include <net/ncsi.h>
|
||||
#include <net/net_namespace.h>
|
||||
#include <net/sock.h>
|
||||
|
||||
#include "internal.h"
|
||||
#include "ncsi-pkt.h"
|
||||
|
||||
u32 ncsi_calculate_checksum(unsigned char *data, int len)
|
||||
{
|
||||
u32 checksum = 0;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i += 2)
|
||||
checksum += (((u32)data[i] << 8) | data[i + 1]);
|
||||
|
||||
checksum = (~checksum + 1);
|
||||
return checksum;
|
||||
}
|
||||
|
||||
/* This function should be called after the data area has been
|
||||
* populated completely.
|
||||
*/
|
||||
static void ncsi_cmd_build_header(struct ncsi_pkt_hdr *h,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
u32 checksum;
|
||||
__be32 *pchecksum;
|
||||
|
||||
h->mc_id = 0;
|
||||
h->revision = NCSI_PKT_REVISION;
|
||||
h->reserved = 0;
|
||||
h->id = nca->id;
|
||||
h->type = nca->type;
|
||||
h->channel = NCSI_TO_CHANNEL(nca->package,
|
||||
nca->channel);
|
||||
h->length = htons(nca->payload);
|
||||
h->reserved1[0] = 0;
|
||||
h->reserved1[1] = 0;
|
||||
|
||||
/* Fill with calculated checksum */
|
||||
checksum = ncsi_calculate_checksum((unsigned char *)h,
|
||||
sizeof(*h) + nca->payload);
|
||||
pchecksum = (__be32 *)((void *)h + sizeof(struct ncsi_pkt_hdr) +
|
||||
nca->payload);
|
||||
*pchecksum = htonl(checksum);
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_default(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_sp(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_sp_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_sp_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->hw_arbitration = nca->bytes[0];
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_dc(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_dc_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_dc_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->ald = nca->bytes[0];
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_rc(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_rc_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_rc_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_ae(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_ae_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_ae_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->mc_id = nca->bytes[0];
|
||||
cmd->mode = htonl(nca->dwords[1]);
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_sl(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_sl_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_sl_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->mode = htonl(nca->dwords[0]);
|
||||
cmd->oem_mode = htonl(nca->dwords[1]);
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_svf(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_svf_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_svf_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->vlan = htons(nca->words[0]);
|
||||
cmd->index = nca->bytes[2];
|
||||
cmd->enable = nca->bytes[3];
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_ev(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_ev_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_ev_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->mode = nca->bytes[0];
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_sma(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_sma_pkt *cmd;
|
||||
int i;
|
||||
|
||||
cmd = (struct ncsi_cmd_sma_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
for (i = 0; i < 6; i++)
|
||||
cmd->mac[i] = nca->bytes[i];
|
||||
cmd->index = nca->bytes[6];
|
||||
cmd->at_e = nca->bytes[7];
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_ebf(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_ebf_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_ebf_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->mode = htonl(nca->dwords[0]);
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_egmf(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_egmf_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_egmf_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->mode = htonl(nca->dwords[0]);
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ncsi_cmd_handler_snfc(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_cmd_snfc_pkt *cmd;
|
||||
|
||||
cmd = (struct ncsi_cmd_snfc_pkt *)skb_put(skb, sizeof(*cmd));
|
||||
memset(cmd, 0, sizeof(*cmd));
|
||||
cmd->mode = nca->bytes[0];
|
||||
ncsi_cmd_build_header(&cmd->cmd.common, nca);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct ncsi_cmd_handler {
|
||||
unsigned char type;
|
||||
int payload;
|
||||
int (*handler)(struct sk_buff *skb,
|
||||
struct ncsi_cmd_arg *nca);
|
||||
} ncsi_cmd_handlers[] = {
|
||||
{ NCSI_PKT_CMD_CIS, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_SP, 4, ncsi_cmd_handler_sp },
|
||||
{ NCSI_PKT_CMD_DP, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_EC, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_DC, 4, ncsi_cmd_handler_dc },
|
||||
{ NCSI_PKT_CMD_RC, 4, ncsi_cmd_handler_rc },
|
||||
{ NCSI_PKT_CMD_ECNT, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_DCNT, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_AE, 8, ncsi_cmd_handler_ae },
|
||||
{ NCSI_PKT_CMD_SL, 8, ncsi_cmd_handler_sl },
|
||||
{ NCSI_PKT_CMD_GLS, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_SVF, 4, ncsi_cmd_handler_svf },
|
||||
{ NCSI_PKT_CMD_EV, 4, ncsi_cmd_handler_ev },
|
||||
{ NCSI_PKT_CMD_DV, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_SMA, 8, ncsi_cmd_handler_sma },
|
||||
{ NCSI_PKT_CMD_EBF, 4, ncsi_cmd_handler_ebf },
|
||||
{ NCSI_PKT_CMD_DBF, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_EGMF, 4, ncsi_cmd_handler_egmf },
|
||||
{ NCSI_PKT_CMD_DGMF, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_SNFC, 4, ncsi_cmd_handler_snfc },
|
||||
{ NCSI_PKT_CMD_GVI, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_GC, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_GP, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_GCPS, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_GNS, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_GNPTS, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_GPS, 0, ncsi_cmd_handler_default },
|
||||
{ NCSI_PKT_CMD_OEM, 0, NULL },
|
||||
{ NCSI_PKT_CMD_PLDM, 0, NULL },
|
||||
{ NCSI_PKT_CMD_GPUUID, 0, ncsi_cmd_handler_default }
|
||||
};
|
||||
|
||||
static struct ncsi_request *ncsi_alloc_command(struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_dev_priv *ndp = nca->ndp;
|
||||
struct ncsi_dev *nd = &ndp->ndev;
|
||||
struct net_device *dev = nd->dev;
|
||||
int hlen = LL_RESERVED_SPACE(dev);
|
||||
int tlen = dev->needed_tailroom;
|
||||
int len = hlen + tlen;
|
||||
struct sk_buff *skb;
|
||||
struct ncsi_request *nr;
|
||||
|
||||
nr = ncsi_alloc_request(ndp, nca->driven);
|
||||
if (!nr)
|
||||
return NULL;
|
||||
|
||||
/* NCSI command packet has 16-bytes header, payload, 4 bytes checksum.
|
||||
* The packet needs padding if its payload is less than 26 bytes to
|
||||
* meet 64 bytes minimal ethernet frame length.
|
||||
*/
|
||||
len += sizeof(struct ncsi_cmd_pkt_hdr) + 4;
|
||||
if (nca->payload < 26)
|
||||
len += 26;
|
||||
else
|
||||
len += nca->payload;
|
||||
|
||||
/* Allocate skb */
|
||||
skb = alloc_skb(len, GFP_ATOMIC);
|
||||
if (!skb) {
|
||||
ncsi_free_request(nr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nr->cmd = skb;
|
||||
skb_reserve(skb, hlen);
|
||||
skb_reset_network_header(skb);
|
||||
|
||||
skb->dev = dev;
|
||||
skb->protocol = htons(ETH_P_NCSI);
|
||||
|
||||
return nr;
|
||||
}
|
||||
|
||||
int ncsi_xmit_cmd(struct ncsi_cmd_arg *nca)
|
||||
{
|
||||
struct ncsi_request *nr;
|
||||
struct ethhdr *eh;
|
||||
struct ncsi_cmd_handler *nch = NULL;
|
||||
int i, ret;
|
||||
|
||||
/* Search for the handler */
|
||||
for (i = 0; i < ARRAY_SIZE(ncsi_cmd_handlers); i++) {
|
||||
if (ncsi_cmd_handlers[i].type == nca->type) {
|
||||
if (ncsi_cmd_handlers[i].handler)
|
||||
nch = &ncsi_cmd_handlers[i];
|
||||
else
|
||||
nch = NULL;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!nch) {
|
||||
netdev_err(nca->ndp->ndev.dev,
|
||||
"Cannot send packet with type 0x%02x\n", nca->type);
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
/* Get packet payload length and allocate the request */
|
||||
nca->payload = nch->payload;
|
||||
nr = ncsi_alloc_command(nca);
|
||||
if (!nr)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Prepare the packet */
|
||||
nca->id = nr->id;
|
||||
ret = nch->handler(nr->cmd, nca);
|
||||
if (ret) {
|
||||
ncsi_free_request(nr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Fill the ethernet header */
|
||||
eh = (struct ethhdr *)skb_push(nr->cmd, sizeof(*eh));
|
||||
eh->h_proto = htons(ETH_P_NCSI);
|
||||
eth_broadcast_addr(eh->h_dest);
|
||||
eth_broadcast_addr(eh->h_source);
|
||||
|
||||
/* Start the timer for the request that might not have
|
||||
* corresponding response. Given NCSI is an internal
|
||||
* connection a 1 second delay should be sufficient.
|
||||
*/
|
||||
nr->enabled = true;
|
||||
mod_timer(&nr->timer, jiffies + 1 * HZ);
|
||||
|
||||
/* Send NCSI packet */
|
||||
skb_get(nr->cmd);
|
||||
ret = dev_queue_xmit(nr->cmd);
|
||||
if (ret < 0) {
|
||||
ncsi_free_request(nr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,415 @@
|
|||
/*
|
||||
* Copyright Gavin Shan, IBM Corporation 2016.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
#ifndef __NCSI_PKT_H__
|
||||
#define __NCSI_PKT_H__
|
||||
|
||||
struct ncsi_pkt_hdr {
|
||||
unsigned char mc_id; /* Management controller ID */
|
||||
unsigned char revision; /* NCSI version - 0x01 */
|
||||
unsigned char reserved; /* Reserved */
|
||||
unsigned char id; /* Packet sequence number */
|
||||
unsigned char type; /* Packet type */
|
||||
unsigned char channel; /* Network controller ID */
|
||||
__be16 length; /* Payload length */
|
||||
__be32 reserved1[2]; /* Reserved */
|
||||
};
|
||||
|
||||
struct ncsi_cmd_pkt_hdr {
|
||||
struct ncsi_pkt_hdr common; /* Common NCSI packet header */
|
||||
};
|
||||
|
||||
struct ncsi_rsp_pkt_hdr {
|
||||
struct ncsi_pkt_hdr common; /* Common NCSI packet header */
|
||||
__be16 code; /* Response code */
|
||||
__be16 reason; /* Response reason */
|
||||
};
|
||||
|
||||
struct ncsi_aen_pkt_hdr {
|
||||
struct ncsi_pkt_hdr common; /* Common NCSI packet header */
|
||||
unsigned char reserved2[3]; /* Reserved */
|
||||
unsigned char type; /* AEN packet type */
|
||||
};
|
||||
|
||||
/* NCSI common command packet */
|
||||
struct ncsi_cmd_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[26];
|
||||
};
|
||||
|
||||
struct ncsi_rsp_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* Select Package */
|
||||
struct ncsi_cmd_sp_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
unsigned char reserved[3]; /* Reserved */
|
||||
unsigned char hw_arbitration; /* HW arbitration */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* Disable Channel */
|
||||
struct ncsi_cmd_dc_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
unsigned char reserved[3]; /* Reserved */
|
||||
unsigned char ald; /* Allow link down */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* Reset Channel */
|
||||
struct ncsi_cmd_rc_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
__be32 reserved; /* Reserved */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* AEN Enable */
|
||||
struct ncsi_cmd_ae_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
unsigned char reserved[3]; /* Reserved */
|
||||
unsigned char mc_id; /* MC ID */
|
||||
__be32 mode; /* AEN working mode */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[18];
|
||||
};
|
||||
|
||||
/* Set Link */
|
||||
struct ncsi_cmd_sl_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
__be32 mode; /* Link working mode */
|
||||
__be32 oem_mode; /* OEM link mode */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[18];
|
||||
};
|
||||
|
||||
/* Set VLAN Filter */
|
||||
struct ncsi_cmd_svf_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
__be16 reserved; /* Reserved */
|
||||
__be16 vlan; /* VLAN ID */
|
||||
__be16 reserved1; /* Reserved */
|
||||
unsigned char index; /* VLAN table index */
|
||||
unsigned char enable; /* Enable or disable */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[14];
|
||||
};
|
||||
|
||||
/* Enable VLAN */
|
||||
struct ncsi_cmd_ev_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
unsigned char reserved[3]; /* Reserved */
|
||||
unsigned char mode; /* VLAN filter mode */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* Set MAC Address */
|
||||
struct ncsi_cmd_sma_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
unsigned char mac[6]; /* MAC address */
|
||||
unsigned char index; /* MAC table index */
|
||||
unsigned char at_e; /* Addr type and operation */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[18];
|
||||
};
|
||||
|
||||
/* Enable Broadcast Filter */
|
||||
struct ncsi_cmd_ebf_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
__be32 mode; /* Filter mode */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* Enable Global Multicast Filter */
|
||||
struct ncsi_cmd_egmf_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
__be32 mode; /* Global MC mode */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* Set NCSI Flow Control */
|
||||
struct ncsi_cmd_snfc_pkt {
|
||||
struct ncsi_cmd_pkt_hdr cmd; /* Command header */
|
||||
unsigned char reserved[3]; /* Reserved */
|
||||
unsigned char mode; /* Flow control mode */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* Get Link Status */
|
||||
struct ncsi_rsp_gls_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 status; /* Link status */
|
||||
__be32 other; /* Other indications */
|
||||
__be32 oem_status; /* OEM link status */
|
||||
__be32 checksum;
|
||||
unsigned char pad[10];
|
||||
};
|
||||
|
||||
/* Get Version ID */
|
||||
struct ncsi_rsp_gvi_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 ncsi_version; /* NCSI version */
|
||||
unsigned char reserved[3]; /* Reserved */
|
||||
unsigned char alpha2; /* NCSI version */
|
||||
unsigned char fw_name[12]; /* f/w name string */
|
||||
__be32 fw_version; /* f/w version */
|
||||
__be16 pci_ids[4]; /* PCI IDs */
|
||||
__be32 mf_id; /* Manufacture ID */
|
||||
__be32 checksum;
|
||||
};
|
||||
|
||||
/* Get Capabilities */
|
||||
struct ncsi_rsp_gc_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 cap; /* Capabilities */
|
||||
__be32 bc_cap; /* Broadcast cap */
|
||||
__be32 mc_cap; /* Multicast cap */
|
||||
__be32 buf_cap; /* Buffering cap */
|
||||
__be32 aen_cap; /* AEN cap */
|
||||
unsigned char vlan_cnt; /* VLAN filter count */
|
||||
unsigned char mixed_cnt; /* Mix filter count */
|
||||
unsigned char mc_cnt; /* MC filter count */
|
||||
unsigned char uc_cnt; /* UC filter count */
|
||||
unsigned char reserved[2]; /* Reserved */
|
||||
unsigned char vlan_mode; /* VLAN mode */
|
||||
unsigned char channel_cnt; /* Channel count */
|
||||
__be32 checksum; /* Checksum */
|
||||
};
|
||||
|
||||
/* Get Parameters */
|
||||
struct ncsi_rsp_gp_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
unsigned char mac_cnt; /* Number of MAC addr */
|
||||
unsigned char reserved[2]; /* Reserved */
|
||||
unsigned char mac_enable; /* MAC addr enable flags */
|
||||
unsigned char vlan_cnt; /* VLAN tag count */
|
||||
unsigned char reserved1; /* Reserved */
|
||||
__be16 vlan_enable; /* VLAN tag enable flags */
|
||||
__be32 link_mode; /* Link setting */
|
||||
__be32 bc_mode; /* BC filter mode */
|
||||
__be32 valid_modes; /* Valid mode parameters */
|
||||
unsigned char vlan_mode; /* VLAN mode */
|
||||
unsigned char fc_mode; /* Flow control mode */
|
||||
unsigned char reserved2[2]; /* Reserved */
|
||||
__be32 aen_mode; /* AEN mode */
|
||||
unsigned char mac[6]; /* Supported MAC addr */
|
||||
__be16 vlan; /* Supported VLAN tags */
|
||||
__be32 checksum; /* Checksum */
|
||||
};
|
||||
|
||||
/* Get Controller Packet Statistics */
|
||||
struct ncsi_rsp_gcps_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 cnt_hi; /* Counter cleared */
|
||||
__be32 cnt_lo; /* Counter cleared */
|
||||
__be32 rx_bytes; /* Rx bytes */
|
||||
__be32 tx_bytes; /* Tx bytes */
|
||||
__be32 rx_uc_pkts; /* Rx UC packets */
|
||||
__be32 rx_mc_pkts; /* Rx MC packets */
|
||||
__be32 rx_bc_pkts; /* Rx BC packets */
|
||||
__be32 tx_uc_pkts; /* Tx UC packets */
|
||||
__be32 tx_mc_pkts; /* Tx MC packets */
|
||||
__be32 tx_bc_pkts; /* Tx BC packets */
|
||||
__be32 fcs_err; /* FCS errors */
|
||||
__be32 align_err; /* Alignment errors */
|
||||
__be32 false_carrier; /* False carrier detection */
|
||||
__be32 runt_pkts; /* Rx runt packets */
|
||||
__be32 jabber_pkts; /* Rx jabber packets */
|
||||
__be32 rx_pause_xon; /* Rx pause XON frames */
|
||||
__be32 rx_pause_xoff; /* Rx XOFF frames */
|
||||
__be32 tx_pause_xon; /* Tx XON frames */
|
||||
__be32 tx_pause_xoff; /* Tx XOFF frames */
|
||||
__be32 tx_s_collision; /* Single collision frames */
|
||||
__be32 tx_m_collision; /* Multiple collision frames */
|
||||
__be32 l_collision; /* Late collision frames */
|
||||
__be32 e_collision; /* Excessive collision frames */
|
||||
__be32 rx_ctl_frames; /* Rx control frames */
|
||||
__be32 rx_64_frames; /* Rx 64-bytes frames */
|
||||
__be32 rx_127_frames; /* Rx 65-127 bytes frames */
|
||||
__be32 rx_255_frames; /* Rx 128-255 bytes frames */
|
||||
__be32 rx_511_frames; /* Rx 256-511 bytes frames */
|
||||
__be32 rx_1023_frames; /* Rx 512-1023 bytes frames */
|
||||
__be32 rx_1522_frames; /* Rx 1024-1522 bytes frames */
|
||||
__be32 rx_9022_frames; /* Rx 1523-9022 bytes frames */
|
||||
__be32 tx_64_frames; /* Tx 64-bytes frames */
|
||||
__be32 tx_127_frames; /* Tx 65-127 bytes frames */
|
||||
__be32 tx_255_frames; /* Tx 128-255 bytes frames */
|
||||
__be32 tx_511_frames; /* Tx 256-511 bytes frames */
|
||||
__be32 tx_1023_frames; /* Tx 512-1023 bytes frames */
|
||||
__be32 tx_1522_frames; /* Tx 1024-1522 bytes frames */
|
||||
__be32 tx_9022_frames; /* Tx 1523-9022 bytes frames */
|
||||
__be32 rx_valid_bytes; /* Rx valid bytes */
|
||||
__be32 rx_runt_pkts; /* Rx error runt packets */
|
||||
__be32 rx_jabber_pkts; /* Rx error jabber packets */
|
||||
__be32 checksum; /* Checksum */
|
||||
};
|
||||
|
||||
/* Get NCSI Statistics */
|
||||
struct ncsi_rsp_gns_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 rx_cmds; /* Rx NCSI commands */
|
||||
__be32 dropped_cmds; /* Dropped commands */
|
||||
__be32 cmd_type_errs; /* Command type errors */
|
||||
__be32 cmd_csum_errs; /* Command checksum errors */
|
||||
__be32 rx_pkts; /* Rx NCSI packets */
|
||||
__be32 tx_pkts; /* Tx NCSI packets */
|
||||
__be32 tx_aen_pkts; /* Tx AEN packets */
|
||||
__be32 checksum; /* Checksum */
|
||||
};
|
||||
|
||||
/* Get NCSI Pass-through Statistics */
|
||||
struct ncsi_rsp_gnpts_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 tx_pkts; /* Tx packets */
|
||||
__be32 tx_dropped; /* Tx dropped packets */
|
||||
__be32 tx_channel_err; /* Tx channel errors */
|
||||
__be32 tx_us_err; /* Tx undersize errors */
|
||||
__be32 rx_pkts; /* Rx packets */
|
||||
__be32 rx_dropped; /* Rx dropped packets */
|
||||
__be32 rx_channel_err; /* Rx channel errors */
|
||||
__be32 rx_us_err; /* Rx undersize errors */
|
||||
__be32 rx_os_err; /* Rx oversize errors */
|
||||
__be32 checksum; /* Checksum */
|
||||
};
|
||||
|
||||
/* Get package status */
|
||||
struct ncsi_rsp_gps_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
__be32 status; /* Hardware arbitration status */
|
||||
__be32 checksum;
|
||||
};
|
||||
|
||||
/* Get package UUID */
|
||||
struct ncsi_rsp_gpuuid_pkt {
|
||||
struct ncsi_rsp_pkt_hdr rsp; /* Response header */
|
||||
unsigned char uuid[16]; /* UUID */
|
||||
__be32 checksum;
|
||||
};
|
||||
|
||||
/* AEN: Link State Change */
|
||||
struct ncsi_aen_lsc_pkt {
|
||||
struct ncsi_aen_pkt_hdr aen; /* AEN header */
|
||||
__be32 status; /* Link status */
|
||||
__be32 oem_status; /* OEM link status */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[14];
|
||||
};
|
||||
|
||||
/* AEN: Configuration Required */
|
||||
struct ncsi_aen_cr_pkt {
|
||||
struct ncsi_aen_pkt_hdr aen; /* AEN header */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[22];
|
||||
};
|
||||
|
||||
/* AEN: Host Network Controller Driver Status Change */
|
||||
struct ncsi_aen_hncdsc_pkt {
|
||||
struct ncsi_aen_pkt_hdr aen; /* AEN header */
|
||||
__be32 status; /* Status */
|
||||
__be32 checksum; /* Checksum */
|
||||
unsigned char pad[18];
|
||||
};
|
||||
|
||||
/* NCSI packet revision */
|
||||
#define NCSI_PKT_REVISION 0x01
|
||||
|
||||
/* NCSI packet commands */
|
||||
#define NCSI_PKT_CMD_CIS 0x00 /* Clear Initial State */
|
||||
#define NCSI_PKT_CMD_SP 0x01 /* Select Package */
|
||||
#define NCSI_PKT_CMD_DP 0x02 /* Deselect Package */
|
||||
#define NCSI_PKT_CMD_EC 0x03 /* Enable Channel */
|
||||
#define NCSI_PKT_CMD_DC 0x04 /* Disable Channel */
|
||||
#define NCSI_PKT_CMD_RC 0x05 /* Reset Channel */
|
||||
#define NCSI_PKT_CMD_ECNT 0x06 /* Enable Channel Network Tx */
|
||||
#define NCSI_PKT_CMD_DCNT 0x07 /* Disable Channel Network Tx */
|
||||
#define NCSI_PKT_CMD_AE 0x08 /* AEN Enable */
|
||||
#define NCSI_PKT_CMD_SL 0x09 /* Set Link */
|
||||
#define NCSI_PKT_CMD_GLS 0x0a /* Get Link */
|
||||
#define NCSI_PKT_CMD_SVF 0x0b /* Set VLAN Filter */
|
||||
#define NCSI_PKT_CMD_EV 0x0c /* Enable VLAN */
|
||||
#define NCSI_PKT_CMD_DV 0x0d /* Disable VLAN */
|
||||
#define NCSI_PKT_CMD_SMA 0x0e /* Set MAC address */
|
||||
#define NCSI_PKT_CMD_EBF 0x10 /* Enable Broadcast Filter */
|
||||
#define NCSI_PKT_CMD_DBF 0x11 /* Disable Broadcast Filter */
|
||||
#define NCSI_PKT_CMD_EGMF 0x12 /* Enable Global Multicast Filter */
|
||||
#define NCSI_PKT_CMD_DGMF 0x13 /* Disable Global Multicast Filter */
|
||||
#define NCSI_PKT_CMD_SNFC 0x14 /* Set NCSI Flow Control */
|
||||
#define NCSI_PKT_CMD_GVI 0x15 /* Get Version ID */
|
||||
#define NCSI_PKT_CMD_GC 0x16 /* Get Capabilities */
|
||||
#define NCSI_PKT_CMD_GP 0x17 /* Get Parameters */
|
||||
#define NCSI_PKT_CMD_GCPS 0x18 /* Get Controller Packet Statistics */
|
||||
#define NCSI_PKT_CMD_GNS 0x19 /* Get NCSI Statistics */
|
||||
#define NCSI_PKT_CMD_GNPTS 0x1a /* Get NCSI Pass-throu Statistics */
|
||||
#define NCSI_PKT_CMD_GPS 0x1b /* Get package status */
|
||||
#define NCSI_PKT_CMD_OEM 0x50 /* OEM */
|
||||
#define NCSI_PKT_CMD_PLDM 0x51 /* PLDM request over NCSI over RBT */
|
||||
#define NCSI_PKT_CMD_GPUUID 0x52 /* Get package UUID */
|
||||
|
||||
/* NCSI packet responses */
|
||||
#define NCSI_PKT_RSP_CIS (NCSI_PKT_CMD_CIS + 0x80)
|
||||
#define NCSI_PKT_RSP_SP (NCSI_PKT_CMD_SP + 0x80)
|
||||
#define NCSI_PKT_RSP_DP (NCSI_PKT_CMD_DP + 0x80)
|
||||
#define NCSI_PKT_RSP_EC (NCSI_PKT_CMD_EC + 0x80)
|
||||
#define NCSI_PKT_RSP_DC (NCSI_PKT_CMD_DC + 0x80)
|
||||
#define NCSI_PKT_RSP_RC (NCSI_PKT_CMD_RC + 0x80)
|
||||
#define NCSI_PKT_RSP_ECNT (NCSI_PKT_CMD_ECNT + 0x80)
|
||||
#define NCSI_PKT_RSP_DCNT (NCSI_PKT_CMD_DCNT + 0x80)
|
||||
#define NCSI_PKT_RSP_AE (NCSI_PKT_CMD_AE + 0x80)
|
||||
#define NCSI_PKT_RSP_SL (NCSI_PKT_CMD_SL + 0x80)
|
||||
#define NCSI_PKT_RSP_GLS (NCSI_PKT_CMD_GLS + 0x80)
|
||||
#define NCSI_PKT_RSP_SVF (NCSI_PKT_CMD_SVF + 0x80)
|
||||
#define NCSI_PKT_RSP_EV (NCSI_PKT_CMD_EV + 0x80)
|
||||
#define NCSI_PKT_RSP_DV (NCSI_PKT_CMD_DV + 0x80)
|
||||
#define NCSI_PKT_RSP_SMA (NCSI_PKT_CMD_SMA + 0x80)
|
||||
#define NCSI_PKT_RSP_EBF (NCSI_PKT_CMD_EBF + 0x80)
|
||||
#define NCSI_PKT_RSP_DBF (NCSI_PKT_CMD_DBF + 0x80)
|
||||
#define NCSI_PKT_RSP_EGMF (NCSI_PKT_CMD_EGMF + 0x80)
|
||||
#define NCSI_PKT_RSP_DGMF (NCSI_PKT_CMD_DGMF + 0x80)
|
||||
#define NCSI_PKT_RSP_SNFC (NCSI_PKT_CMD_SNFC + 0x80)
|
||||
#define NCSI_PKT_RSP_GVI (NCSI_PKT_CMD_GVI + 0x80)
|
||||
#define NCSI_PKT_RSP_GC (NCSI_PKT_CMD_GC + 0x80)
|
||||
#define NCSI_PKT_RSP_GP (NCSI_PKT_CMD_GP + 0x80)
|
||||
#define NCSI_PKT_RSP_GCPS (NCSI_PKT_CMD_GCPS + 0x80)
|
||||
#define NCSI_PKT_RSP_GNS (NCSI_PKT_CMD_GNS + 0x80)
|
||||
#define NCSI_PKT_RSP_GNPTS (NCSI_PKT_CMD_GNPTS + 0x80)
|
||||
#define NCSI_PKT_RSP_GPS (NCSI_PKT_CMD_GPS + 0x80)
|
||||
#define NCSI_PKT_RSP_OEM (NCSI_PKT_CMD_OEM + 0x80)
|
||||
#define NCSI_PKT_RSP_PLDM (NCSI_PKT_CMD_PLDM + 0x80)
|
||||
#define NCSI_PKT_RSP_GPUUID (NCSI_PKT_CMD_GPUUID + 0x80)
|
||||
|
||||
/* NCSI response code/reason */
|
||||
#define NCSI_PKT_RSP_C_COMPLETED 0x0000 /* Command Completed */
|
||||
#define NCSI_PKT_RSP_C_FAILED 0x0001 /* Command Failed */
|
||||
#define NCSI_PKT_RSP_C_UNAVAILABLE 0x0002 /* Command Unavailable */
|
||||
#define NCSI_PKT_RSP_C_UNSUPPORTED 0x0003 /* Command Unsupported */
|
||||
#define NCSI_PKT_RSP_R_NO_ERROR 0x0000 /* No Error */
|
||||
#define NCSI_PKT_RSP_R_INTERFACE 0x0001 /* Interface not ready */
|
||||
#define NCSI_PKT_RSP_R_PARAM 0x0002 /* Invalid Parameter */
|
||||
#define NCSI_PKT_RSP_R_CHANNEL 0x0003 /* Channel not Ready */
|
||||
#define NCSI_PKT_RSP_R_PACKAGE 0x0004 /* Package not Ready */
|
||||
#define NCSI_PKT_RSP_R_LENGTH 0x0005 /* Invalid payload length */
|
||||
#define NCSI_PKT_RSP_R_UNKNOWN 0x7fff /* Command type unsupported */
|
||||
|
||||
/* NCSI AEN packet type */
|
||||
#define NCSI_PKT_AEN 0xFF /* AEN Packet */
|
||||
#define NCSI_PKT_AEN_LSC 0x00 /* Link status change */
|
||||
#define NCSI_PKT_AEN_CR 0x01 /* Configuration required */
|
||||
#define NCSI_PKT_AEN_HNCDSC 0x02 /* HNC driver status change */
|
||||
|
||||
#endif /* __NCSI_PKT_H__ */
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue