01 Sep, 2019

1 commit

  • This patch adds handlers for PLDM over NC-SI command response.

    This enables NC-SI driver recognizes the packet type so the responses
    don't get dropped as unknown packet type.

    PLDM over NC-SI are not handled in kernel driver for now, but can be
    passed back to user space via Netlink for further handling.

    Signed-off-by: Ben Wei
    Signed-off-by: David S. Miller

    Ben Wei
     

28 Aug, 2019

1 commit


23 Aug, 2019

1 commit


21 Aug, 2019

1 commit


31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    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

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 3029 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

24 Apr, 2019

1 commit

  • Previously BMC's MAC address is calculated by simply adding 1 to the
    last byte of network controller's MAC address, and it produces incorrect
    result when network controller's MAC address ends with 0xFF.

    The problem can be fixed by calling eth_addr_inc() function to increment
    MAC address; besides, the MAC address is also validated before assigning
    to BMC.

    Fixes: cb10c7c0dfd9 ("net/ncsi: Add NCSI Broadcom OEM command")
    Signed-off-by: Tao Ren
    Acked-by: Jakub Kicinski
    Acked-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Tao Ren
     

28 Nov, 2018

1 commit

  • This patch adds OEM Mellanox commands and response handling. It also
    defines OEM Get MAC Address handler to get and configure the device.

    ncsi_oem_gma_handler_mlx: This handler send NCSI mellanox command for
    getting mac address.
    ncsi_rsp_handler_oem_mlx: This handles response received for all
    mellanox OEM commands.
    ncsi_rsp_handler_oem_mlx_gma: This handles get mac address response and
    set it to device.

    Signed-off-by: Vijay Khemka
    Signed-off-by: David S. Miller

    Vijay Khemka
     

18 Nov, 2018

1 commit

  • This patch extends the ncsi-netlink interface with two new commands and
    three new attributes to configure multiple packages and/or channels at
    once, and configure specific failover modes.

    NCSI_CMD_SET_PACKAGE mask and NCSI_CMD_SET_CHANNEL_MASK set a whitelist
    of packages or channels allowed to be configured with the
    NCSI_ATTR_PACKAGE_MASK and NCSI_ATTR_CHANNEL_MASK attributes
    respectively. If one of these whitelists is set only packages or
    channels matching the whitelist are considered for the channel queue in
    ncsi_choose_active_channel().

    These commands may also use the NCSI_ATTR_MULTI_FLAG to signal that
    multiple packages or channels may be configured simultaneously. NCSI
    hardware arbitration (HWA) must be available in order to enable
    multi-package mode. Multi-channel mode is always available.

    If the NCSI_ATTR_CHANNEL_ID attribute is present in the
    NCSI_CMD_SET_CHANNEL_MASK command the it sets the preferred channel as
    with the NCSI_CMD_SET_INTERFACE command. The combination of preferred
    channel and channel whitelist defines a primary channel and the allowed
    failover channels.
    If the NCSI_ATTR_MULTI_FLAG attribute is also present then the preferred
    channel is configured for Tx/Rx and the other channels are enabled only
    for Rx.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

18 Oct, 2018

1 commit

  • This patch adds OEM Broadcom commands and response handling. It also
    defines OEM Get MAC Address handler to get and configure the device.

    ncsi_oem_gma_handler_bcm: This handler send NCSI broadcom command for
    getting mac address.
    ncsi_rsp_handler_oem_bcm: This handles response received for all
    broadcom OEM commands.
    ncsi_rsp_handler_oem_bcm_gma: This handles get mac address response and
    set it to device.

    Signed-off-by: Vijay Khemka
    Reviewed-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Vijay Khemka
     

16 Oct, 2018

1 commit

  • The new command (NCSI_CMD_SEND_CMD) is added to allow user space application
    to send NC-SI command to the network card.
    Also, add a new attribute (NCSI_ATTR_DATA) for transferring request and response.

    The work flow is as below.

    Request:
    User space application
    -> Netlink interface (msg)
    -> new Netlink handler - ncsi_send_cmd_nl()
    -> ncsi_xmit_cmd()

    Response:
    Response received - ncsi_rcv_rsp()
    -> internal response handler - ncsi_rsp_handler_xxx()
    -> ncsi_rsp_handler_netlink()
    -> ncsi_send_netlink_rsp ()
    -> Netlink interface (msg)
    -> user space application

    Command timeout - ncsi_request_timeout()
    -> ncsi_send_netlink_timeout ()
    -> Netlink interface (msg with zero data length)
    -> user space application

    Error:
    Error detected
    -> ncsi_send_netlink_err ()
    -> Netlink interface (err msg)
    -> user space application

    Signed-off-by: Justin Lee
    Reviewed-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Justin.Lee1@Dell.com
     

06 Oct, 2018

1 commit

  • This patch adds OEM commands and response handling. It also defines OEM
    command and response structure as per NCSI specification along with its
    handlers.

    ncsi_cmd_handler_oem: This is a generic command request handler for OEM
    commands
    ncsi_rsp_handler_oem: This is a generic response handler for OEM commands

    Signed-off-by: Vijay Khemka
    Reviewed-by: Justin Lee
    Reviewed-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Vijay Khemka
     

03 Jun, 2018

1 commit

  • ncsi_rsp_handler_gc() allocates the filter arrays using GFP_KERNEL in
    softirq context, causing the below backtrace. This allocation is only a
    few dozen bytes during probing so allocate with GFP_ATOMIC instead.

    [ 42.813372] BUG: sleeping function called from invalid context at mm/slab.h:416
    [ 42.820900] in_atomic(): 1, irqs_disabled(): 0, pid: 213, name: kworker/0:1
    [ 42.827893] INFO: lockdep is turned off.
    [ 42.832023] CPU: 0 PID: 213 Comm: kworker/0:1 Tainted: G W 4.13.16-01441-gad99b38 #65
    [ 42.841007] Hardware name: Generic DT based system
    [ 42.845966] Workqueue: events ncsi_dev_work
    [ 42.850251] [] (unwind_backtrace) from [] (show_stack+0x20/0x24)
    [ 42.858046] [] (show_stack) from [] (dump_stack+0x20/0x28)
    [ 42.865309] [] (dump_stack) from [] (___might_sleep+0x230/0x2b0)
    [ 42.873241] [] (___might_sleep) from [] (__might_sleep+0x6c/0xac)
    [ 42.881129] [] (__might_sleep) from [] (__kmalloc+0x210/0x2fc)
    [ 42.888737] [] (__kmalloc) from [] (ncsi_rsp_handler_gc+0xd0/0x170)
    [ 42.896770] [] (ncsi_rsp_handler_gc) from [] (ncsi_rcv_rsp+0x16c/0x1d4)
    [ 42.905314] [] (ncsi_rcv_rsp) from [] (__netif_receive_skb_core+0x3c8/0xb50)
    [ 42.914158] [] (__netif_receive_skb_core) from [] (__netif_receive_skb+0x20/0x7c)
    [ 42.923420] [] (__netif_receive_skb) from [] (netif_receive_skb_internal+0x78/0x6a4)
    [ 42.932931] [] (netif_receive_skb_internal) from [] (netif_receive_skb+0x78/0x158)
    [ 42.942292] [] (netif_receive_skb) from [] (ftgmac100_poll+0x43c/0x4e8)
    [ 42.950855] [] (ftgmac100_poll) from [] (net_rx_action+0x278/0x4c4)
    [ 42.958918] [] (net_rx_action) from [] (__do_softirq+0xe0/0x4c4)
    [ 42.966716] [] (__do_softirq) from [] (do_softirq.part.4+0x50/0x78)
    [ 42.974756] [] (do_softirq.part.4) from [] (__local_bh_enable_ip+0xf8/0x11c)
    [ 42.983579] [] (__local_bh_enable_ip) from [] (__dev_queue_xmit+0x260/0x890)
    [ 42.992392] [] (__dev_queue_xmit) from [] (dev_queue_xmit+0x1c/0x20)
    [ 43.000689] [] (dev_queue_xmit) from [] (ncsi_xmit_cmd+0x1c0/0x244)
    [ 43.008763] [] (ncsi_xmit_cmd) from [] (ncsi_dev_work+0x2e0/0x4c8)
    [ 43.016725] [] (ncsi_dev_work) from [] (process_one_work+0x214/0x6f8)
    [ 43.024940] [] (process_one_work) from [] (worker_thread+0x48/0x558)
    [ 43.033070] [] (worker_thread) from [] (kthread+0x130/0x174)
    [ 43.040506] [] (kthread) from [] (ret_from_fork+0x14/0x24)

    Fixes: 062b3e1b6d4f ("net/ncsi: Refactor MAC, VLAN filters")
    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

18 May, 2018

1 commit

  • We recently refactored this code and introduced a static checker
    warning. Smatch complains that if cmd->index is zero then we would
    underflow the arrays. That's obviously true.

    The question is whether we prevent cmd->index from being zero at a
    different level. I've looked at the code and I don't immediately see
    a check for that.

    Fixes: 062b3e1b6d4f ("net/ncsi: Refactor MAC, VLAN filters")
    Signed-off-by: Dan Carpenter
    Signed-off-by: David S. Miller

    Dan Carpenter
     

18 Apr, 2018

1 commit

  • The NCSI driver defines a generic ncsi_channel_filter struct that can be
    used to store arbitrarily formatted filters, and several generic methods
    of accessing data stored in such a filter.
    However in both the driver and as defined in the NCSI specification
    there are only two actual filters: VLAN ID filters and MAC address
    filters. The splitting of the MAC filter into unicast, multicast, and
    mixed is also technically not necessary as these are stored in the same
    location in hardware.

    To save complexity, particularly in the set up and accessing of these
    generic filters, remove them in favour of two specific structs. These
    can be acted on directly and do not need several generic helper
    functions to use.

    This also fixes a memory error found by KASAN on ARM32 (which is not
    upstream yet), where response handlers accessing a filter's data field
    could write past allocated memory.

    [ 114.926512] ==================================================================
    [ 114.933861] BUG: KASAN: slab-out-of-bounds in ncsi_configure_channel+0x4b8/0xc58
    [ 114.941304] Read of size 2 at addr 94888558 by task kworker/0:2/546
    [ 114.947593]
    [ 114.949146] CPU: 0 PID: 546 Comm: kworker/0:2 Not tainted 4.16.0-rc6-00119-ge156398bfcad #13
    ...
    [ 115.170233] The buggy address belongs to the object at 94888540
    [ 115.170233] which belongs to the cache kmalloc-32 of size 32
    [ 115.181917] The buggy address is located 24 bytes inside of
    [ 115.181917] 32-byte region [94888540, 94888560)
    [ 115.192115] The buggy address belongs to the page:
    [ 115.196943] page:9eeac100 count:1 mapcount:0 mapping:94888000 index:0x94888fc1
    [ 115.204200] flags: 0x100(slab)
    [ 115.207330] raw: 00000100 94888000 94888fc1 0000003f 00000001 9eea2014 9eecaa74 96c003e0
    [ 115.215444] page dumped because: kasan: bad access detected
    [ 115.221036]
    [ 115.222544] Memory state around the buggy address:
    [ 115.227384] 94888400: fb fb fb fb fc fc fc fc 04 fc fc fc fc fc fc fc
    [ 115.233959] 94888480: 00 00 00 fc fc fc fc fc 00 04 fc fc fc fc fc fc
    [ 115.240529] >94888500: 00 00 04 fc fc fc fc fc 00 00 04 fc fc fc fc fc
    [ 115.247077] ^
    [ 115.252523] 94888580: 00 04 fc fc fc fc fc fc 06 fc fc fc fc fc fc fc
    [ 115.259093] 94888600: 00 00 06 fc fc fc fc fc 00 00 04 fc fc fc fc fc
    [ 115.265639] ==================================================================

    Reported-by: Joel Stanley
    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

11 Nov, 2017

2 commits

  • Several response handlers return EBUSY if the data corresponding to the
    command/response pair is already set. There is no reason to return an
    error here; the channel is advertising something as enabled because we
    told it to enable it, and it's possible that the feature has been
    enabled previously.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • The NCSI driver is mostly silent which becomes a headache when trying to
    determine what has occurred on the NCSI connection. This adds additional
    logging in a few key areas such as state transitions and calling out
    certain errors more visibly.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

21 Oct, 2017

1 commit

  • The length of GVI (GetVersionInfo) response packet should be 40 instead
    of 36. This issue was found from /sys/kernel/debug/ncsi/eth0/stats.

    # ethtool --ncsi eth0 swstats
    :
    RESPONSE OK TIMEOUT ERROR
    =======================================
    GVI 0 0 2

    With this applied, no error reported on GVI response packets:

    # ethtool --ncsi eth0 swstats
    :
    RESPONSE OK TIMEOUT ERROR
    =======================================
    GVI 2 0 0

    Signed-off-by: Gavin Shan
    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Gavin Shan
     

29 Aug, 2017

2 commits

  • Make use of the ndo_vlan_rx_{add,kill}_vid callbacks to have the NCSI
    stack process new VLAN tags and configure the channel VLAN filter
    appropriately.
    Several VLAN tags can be set and a "Set VLAN Filter" packet must be sent
    for each one, meaning the ncsi_dev_state_config_svf state must be
    repeated. An internal list of VLAN tags is maintained, and compared
    against the current channel's ncsi_channel_filter in order to keep track
    within the state. VLAN filters are removed in a similar manner, with the
    introduction of the ncsi_dev_state_config_clear_vids state. The maximum
    number of VLAN tag filters is determined by the "Get Capabilities"
    response from the channel.

    Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     
  • Signed-off-by: Samuel Mendoza-Jonas
    Signed-off-by: David S. Miller

    Samuel Mendoza-Jonas
     

04 Oct, 2016

2 commits

  • The original NCSI channel monitoring was implemented based on a
    backoff algorithm: the GLS response should be received in the
    specified interval. Otherwise, the channel is regarded as dead
    and failover should be taken if current channel is an active one.
    There are several problems in the implementation: (A) On BCM5718,
    we found when the IID (Instance ID) in the GLS command packet
    changes from 255 to 1, the response corresponding to IID#1 never
    comes in. It means we cannot make the unfair judgement that the
    channel is dead when one response is missed. (B) The code's
    readability should be improved. (C) We should do failover when
    current channel is active one and the channel monitoring should
    be marked as disabled before doing failover.

    This reworks the channel monitoring to address all above issues.
    The fields for channel monitoring is put into separate struct
    and the state of channel monitoring is predefined. The channel
    is regarded alive if the network controller responses to one of
    two GLS commands or both of them in 5 seconds.

    Signed-off-by: Gavin Shan
    Reviewed-by: Joel Stanley
    Signed-off-by: David S. Miller

    Gavin Shan
     
  • There is only one NCSI request property for now: the response for
    the sent command need drive the workqueue or not. So we had one
    field (@driven) for the purpose. We lost the flexibility to extend
    NCSI request properties.

    This replaces @driven with @flags and @req_flags in NCSI request
    and NCSI command argument struct. Each bit of the newly introduced
    field can be used for one property. No functional changes introduced.

    Signed-off-by: Gavin Shan
    Reviewed-by: Joel Stanley
    Signed-off-by: David S. Miller

    Gavin Shan
     

20 Jul, 2016

3 commits

  • This introduces NCSI AEN packet handlers that result in (A) the
    currently active channel is reconfigured; (B) Currently active
    channel is deconfigured and disabled, another channel is chosen
    as active one and configured. Case (B) won't happen if hardware
    arbitration has been enabled, the channel that was in active
    state is suspended simply.

    Signed-off-by: Gavin Shan
    Acked-by: Joel Stanley
    Signed-off-by: David S. Miller

    Gavin Shan
     
  • This manages NCSI packages and channels:

    * The available packages and channels are enumerated in the first
    time of calling ncsi_start_dev(). The channels' capabilities are
    probed in the meanwhile. The NCSI network topology won't change
    until the NCSI device is destroyed.
    * There in a queue in every NCSI device. The element in the queue,
    channel, is waiting for configuration (bringup) or suspending
    (teardown). The channel's state (inactive/active) indicates the
    futher action (configuration or suspending) will be applied on the
    channel. Another channel's state (invisible) means the requested
    action is being applied.
    * The hardware arbitration will be enabled if all available packages
    and channels support it. All available channels try to provide
    service when hardware arbitration is enabled. Otherwise, one channel
    is selected as the active one at once.
    * When channel is in active state, meaning it's providing service, a
    timer started to retrieve the channe's link status. If the channel's
    link status fails to be updated in the determined period, the channel
    is going to be reconfigured. It's the error handling implementation
    as defined in NCSI spec.

    Signed-off-by: Gavin Shan
    Acked-by: Joel Stanley
    Signed-off-by: David S. Miller

    Gavin Shan
     
  • The NCSI response packets are sent to MC (Management Controller)
    from the remote end. They are responses of NCSI command packets
    for multiple purposes: completion status of NCSI command packets,
    return NCSI channel's capability or configuration etc.

    This defines struct to represent NCSI response packets and introduces
    function ncsi_rcv_rsp() which will be used to receive NCSI response
    packets and parse them.

    Signed-off-by: Gavin Shan
    Acked-by: Joel Stanley
    Signed-off-by: David S. Miller

    Gavin Shan