iPXE
Data Structures | Enumerations | Functions | Variables
xsigo.c File Reference

Xsigo virtual Ethernet devices. More...

#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/version.h>
#include <ipxe/timer.h>
#include <ipxe/malloc.h>
#include <ipxe/iobuf.h>
#include <ipxe/retry.h>
#include <ipxe/process.h>
#include <ipxe/settings.h>
#include <ipxe/infiniband.h>
#include <ipxe/ib_service.h>
#include <ipxe/ib_cmrc.h>
#include <ipxe/if_ether.h>
#include <ipxe/ethernet.h>
#include <ipxe/eoib.h>
#include <ipxe/xsigo.h>

Go to the source code of this file.

Data Structures

struct  xsigo_device
 A Xsigo device. More...
 
struct  xsigo_manager
 A Xsigo configuration manager. More...
 
struct  xsigo_nic
 A Xsigo virtual Ethernet device. More...
 
struct  xsigo_discovery
 A stage of discovery. More...
 

Enumerations

enum  xsigo_manager_pending { XCM_TX_CONNECT = 0x0001, XCM_TX_REGISTER = 0x0002 }
 Configuration manager pending transmissions. More...
 

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 
static LIST_HEAD (xsigo_devices)
 List of all Xsigo devices. More...
 
static void xsigo_free (struct refcnt *refcnt)
 Free Xsigo device. More...
 
static void xcm_free (struct refcnt *refcnt)
 Free configuration manager. More...
 
static int xve_create (struct xsigo_manager *xcm, union ib_guid *resource, const uint8_t *mac, unsigned long network, unsigned long qkey, const char *name)
 Create virtual Ethernet device. More...
 
static struct xsigo_nicxve_find (struct xsigo_manager *xcm, union ib_guid *resource)
 Find virtual Ethernet device. More...
 
static void xve_destroy (struct xsigo_nic *xve)
 Destroy virtual Ethernet device. More...
 
static int xve_update_mtu (struct xsigo_nic *xve, struct eoib_device *eoib, size_t mtu)
 Update virtual Ethernet device MTU. More...
 
static int xve_open (struct xsigo_nic *xve, struct eoib_device *eoib)
 Open virtual Ethernet device. More...
 
static void xve_close (struct xsigo_nic *xve, struct eoib_device *eoib)
 Close virtual Ethernet device. More...
 
static int xve_update_state (struct xsigo_nic *xve, struct eoib_device *eoib, int open)
 Update virtual Ethernet device administrative state. More...
 
static int xve_update_tca (struct xsigo_nic *xve, struct eoib_device *eoib, struct ib_address_vector *av)
 Update gateway (TCA) More...
 
static const char * xsmp_session_type (unsigned int type)
 Get session message name (for debugging) More...
 
static const char * xsmp_chassis_name (struct xsmp_session_message *msg)
 Extract chassis name (for debugging) More...
 
static const char * xsmp_session_name (struct xsmp_session_message *msg)
 Extract session name (for debugging) More...
 
static int xsmp_tx_session (struct xsigo_manager *xcm, unsigned int type)
 Send session message. More...
 
static int xsmp_tx_session_register (struct xsigo_manager *xcm)
 Send registration message. More...
 
static int xsmp_tx_session_hello (struct xsigo_manager *xcm)
 Send keepalive message. More...
 
static int xsmp_rx_session_hello (struct xsigo_manager *xcm, struct xsmp_session_message *msg __unused)
 Handle received keepalive message. More...
 
static int xsmp_rx_session_confirm (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received registration confirmation message. More...
 
static int xsmp_rx_session_reject (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received registration rejection message. More...
 
static int xsmp_rx_session_shutdown (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received shutdown message. More...
 
static int xsmp_rx_session (struct xsigo_manager *xcm, struct xsmp_session_message *msg)
 Handle received session message. More...
 
static const char * xsmp_xve_type (unsigned int type)
 Get virtual Ethernet message name (for debugging) More...
 
static int xsmp_tx_xve (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Send virtual Ethernet message. More...
 
static int xsmp_tx_xve_params (struct xsigo_manager *xcm, struct xsmp_xve_message *msg, struct xsigo_nic *xve, struct eoib_device *eoib)
 Send virtual Ethernet message including current device parameters. More...
 
static int xsmp_tx_xve_nack (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Send virtual Ethernet error response. More...
 
static int xsmp_tx_xve_notify (struct xsigo_manager *xcm, unsigned int type, struct xsigo_nic *xve, struct eoib_device *eoib)
 Send virtual Ethernet notification. More...
 
static int xsmp_tx_xve_oper (struct xsigo_manager *xcm, struct xsigo_nic *xve, struct eoib_device *eoib)
 Send virtual Ethernet current operational state. More...
 
static int xsmp_rx_xve_modify (struct xsigo_manager *xcm, struct xsmp_xve_message *msg, unsigned int update)
 Handle received virtual Ethernet modification message. More...
 
static int xsmp_rx_xve_install (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet installation message. More...
 
static int xsmp_rx_xve_delete (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet deletion message. More...
 
static int xsmp_rx_xve_update (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet update message. More...
 
static int xsmp_rx_xve_oper_req (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet operational request message. More...
 
static int xsmp_rx_xve_ready (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet readiness message. More...
 
static int xsmp_rx_xve (struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
 Handle received virtual Ethernet message. More...
 
static void xcm_close (struct xsigo_manager *xcm, int rc)
 Close configuration manager connection. More...
 
static void xcm_step (struct xsigo_manager *xcm)
 Send data to configuration manager. More...
 
static int xcm_deliver (struct xsigo_manager *xcm, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
 Receive data from configuration manager. More...
 
static void xcm_reopen (struct retry_timer *timer, int fail __unused)
 Handle configuration manager connection timer expiry. More...
 
static void xcm_keepalive (struct retry_timer *timer, int fail __unused)
 Handle configuration manager keepalive timer expiry. More...
 
static int xcm_create (struct xsigo_device *xdev, struct xsigo_manager_id *id)
 Create configuration manager. More...
 
static struct xsigo_managerxcm_find (struct xsigo_device *xdev, struct xsigo_manager_id *id)
 Find configuration manager. More...
 
static void xcm_destroy (struct xsigo_manager *xcm)
 Destroy configuration manager. More...
 
static int xcm_list (struct xsigo_device *xdev, struct xsigo_manager_id *ids, unsigned int count)
 Synchronise list of configuration managers. More...
 
static void xsigo_xcm_complete (struct ib_device *ibdev, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av __unused)
 Handle configuration manager lookup completion. More...
 
static void xsigo_xds_complete (struct ib_device *ibdev, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av __unused)
 Handle directory service lookup completion. More...
 
static void xsigo_discover (struct retry_timer *timer, int over __unused)
 Discover configuration managers. More...
 
static void xsigo_ib_open (struct retry_timer *opener, int over __unused)
 Open link and start discovery. More...
 
static int xsigo_ib_probe (struct ib_device *ibdev)
 Probe Xsigo device. More...
 
static void xsigo_ib_notify (struct ib_device *ibdev)
 Handle device or link status change. More...
 
static void xsigo_ib_remove (struct ib_device *ibdev)
 Remove Xsigo device. More...
 
static void xsigo_net_notify (struct net_device *netdev, void *priv __unused)
 Handle device or link status change. More...
 

Variables

static union ib_guid xcm_service_id
 Configuration manager service ID. More...
 
static struct interface_operation xcm_xfer_op []
 Configuration manager data transfer interface operations. More...
 
static struct interface_descriptor xcm_xfer_desc
 Configuration manager data transfer interface descriptor. More...
 
static struct process_descriptor xcm_process_desc
 Configuration manager process descriptor. More...
 
static struct xsigo_discovery xsigo_xcm_discovery
 Configuration manager lookup discovery stage. More...
 
static struct xsigo_discovery xsigo_xds_discovery
 Directory service lookup discovery stage. More...
 
struct ib_driver xsigo_ib_driver __ib_driver
 Xsigo Infiniband driver. More...
 
struct net_driver xsigo_net_driver __net_driver
 Xsigo network driver. More...
 

Detailed Description

Xsigo virtual Ethernet devices.

Definition in file xsigo.c.

Enumeration Type Documentation

◆ xsigo_manager_pending

Configuration manager pending transmissions.

Enumerator
XCM_TX_CONNECT 

Send connection request.

XCM_TX_REGISTER 

Send registration message.

Definition at line 105 of file xsigo.c.

105  {
106  /** Send connection request */
107  XCM_TX_CONNECT = 0x0001,
108  /** Send registration message */
109  XCM_TX_REGISTER = 0x0002,
110 };
Send connection request.
Definition: xsigo.c:107
Send registration message.
Definition: xsigo.c:109

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ LIST_HEAD()

static LIST_HEAD ( xsigo_devices  )
static

List of all Xsigo devices.

◆ xsigo_free()

static void xsigo_free ( struct refcnt refcnt)
static

Free Xsigo device.

Parameters
refcntReference count

Definition at line 142 of file xsigo.c.

142  {
143  struct xsigo_device *xdev =
144  container_of ( refcnt, struct xsigo_device, refcnt );
145 
146  /* Sanity checks */
147  assert ( ! timer_running ( &xdev->opener ) );
148  assert ( ! timer_running ( &xdev->discovery ) );
149  assert ( xdev->madx == NULL );
150  assert ( list_empty ( &xdev->managers ) );
151 
152  /* Drop reference to Infiniband device */
153  ibdev_put ( xdev->ibdev );
154 
155  /* Free device */
156  free ( xdev );
157 }
struct retry_timer opener
Link opener timer.
Definition: xsigo.c:63
A reference counter.
Definition: refcnt.h:26
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
struct list_head managers
List of configuration managers.
Definition: xsigo.c:71
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
struct ib_mad_transaction * madx
Discovery management transaction (if any)
Definition: xsigo.c:68
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct retry_timer discovery
Discovery timer.
Definition: xsigo.c:66
static __always_inline void ibdev_put(struct ib_device *ibdev)
Drop reference to Infiniband device.
Definition: infiniband.h:598
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
A Xsigo device.
Definition: xsigo.c:52
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References assert(), container_of, xsigo_device::discovery, free, xsigo_device::ibdev, ibdev_put(), list_empty, xsigo_device::madx, xsigo_device::managers, NULL, and xsigo_device::opener.

Referenced by xsigo_ib_probe().

◆ xcm_free()

static void xcm_free ( struct refcnt refcnt)
static

Free configuration manager.

Parameters
refcntReference count

Definition at line 164 of file xsigo.c.

164  {
165  struct xsigo_manager *xcm =
167 
168  /* Sanity checks */
169  assert ( ! timer_running ( &xcm->reopen ) );
170  assert ( ! timer_running ( &xcm->keepalive ) );
171  assert ( ! process_running ( &xcm->process ) );
172  assert ( list_empty ( &xcm->nics ) );
173 
174  /* Drop reference to Xsigo device */
175  ref_put ( &xcm->xdev->refcnt );
176 
177  /* Free manager */
178  free ( xcm );
179 }
struct refcnt refcnt
Reference count.
Definition: xsigo.c:54
struct process process
Transmission process.
Definition: xsigo.c:94
A reference counter.
Definition: refcnt.h:26
#define list_empty(list)
Test whether a list is empty.
Definition: list.h:136
struct list_head nics
List of virtual Ethernet devices.
Definition: xsigo.c:101
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
assert((readw(&hdr->flags) &(GTF_reading|GTF_writing))==0)
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
A Xsigo configuration manager.
Definition: xsigo.c:75
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
static int process_running(struct process *process)
Check if process is running.
Definition: process.h:175
struct retry_timer reopen
Connection timer.
Definition: xsigo.c:90
struct retry_timer keepalive
Keepalive timer.
Definition: xsigo.c:92
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References assert(), container_of, free, xsigo_manager::keepalive, list_empty, xsigo_manager::nics, xsigo_manager::process, process_running(), ref_put, xsigo_device::refcnt, xsigo_manager::reopen, and xsigo_manager::xdev.

Referenced by xcm_create().

◆ xve_create()

static int xve_create ( struct xsigo_manager xcm,
union ib_guid resource,
const uint8_t mac,
unsigned long  network,
unsigned long  qkey,
const char *  name 
)
static

Create virtual Ethernet device.

Parameters
xcmConfiguration manager
resourceResource identifier
macEthernet MAC
networkNetwork identifier
nameDevice name
Return values
rcReturn status code

Definition at line 198 of file xsigo.c.

200  {
201  struct xsigo_device *xdev = xcm->xdev;
202  struct ib_device *ibdev = xdev->ibdev;
203  struct xsigo_nic *xve;
204  struct ib_address_vector broadcast;
205  int rc;
206 
207  /* Allocate and initialise structure */
208  xve = zalloc ( sizeof ( *xve ) );
209  if ( ! xve ) {
210  rc = -ENOMEM;
211  goto err_alloc;
212  }
213  xve->xcm = xcm;
214  snprintf ( xve->name, sizeof ( xve->name ), "%s", name );
215  memcpy ( &xve->resource, resource, sizeof ( xve->resource ) );
216  memcpy ( xve->mac, mac, ETH_ALEN );
217  xve->network = network;
218  DBGC ( xve, "XVE %s created for %s " IB_GUID_FMT "\n",
219  xve->name, xcm->name, IB_GUID_ARGS ( resource ) );
220  DBGC ( xve, "XVE %s is MAC %s on network %ld\n",
221  xve->name, eth_ntoa ( mac ), network );
222 
223  /* Construct broadcast address vector */
224  memset ( &broadcast, 0, sizeof ( broadcast ) );
225  broadcast.qpn = IB_QPN_BROADCAST;
226  broadcast.qkey = qkey;
227  broadcast.gid_present = 1;
228  broadcast.gid.dwords[0] = htonl ( XVE_PREFIX );
229  broadcast.gid.words[2] = htons ( ibdev->pkey );
230  broadcast.gid.dwords[3] = htonl ( network );
231 
232  /* Create EoIB device */
233  if ( ( rc = eoib_create ( ibdev, xve->mac, &broadcast,
234  xve->name ) ) != 0 ) {
235  DBGC ( xve, "XVE %s could not create EoIB device: %s\n",
236  xve->name, strerror ( rc ) );
237  goto err_create;
238  }
239 
240  /* Add to list of virtual Ethernet devices. Do this only
241  * after creating the EoIB device, so that our net device
242  * notifier won't attempt to send an operational state update
243  * before we have acknowledged the installation.
244  */
245  list_add ( &xve->list, &xcm->nics );
246 
247  return 0;
248 
249  list_del ( &xve->list );
250  err_create:
251  free ( xve );
252  err_alloc:
253  return rc;
254 }
#define XVE_PREFIX
Xsigo virtual Ethernet broadcast GID prefix.
Definition: xsigo.h:35
int eoib_create(struct ib_device *ibdev, const uint8_t *hw_addr, struct ib_address_vector *broadcast, const char *name)
Create EoIB device.
Definition: eoib.c:619
struct list_head list
List of virtual Ethernet devices.
Definition: xsigo.c:117
uint8_t mac[ETH_ALEN]
MAC address.
Definition: xsigo.c:124
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
unsigned long network
Network ID.
Definition: xsigo.c:126
#define DBGC(...)
Definition: compiler.h:505
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
#define htonl(value)
Definition: byteswap.h:133
char name[16]
Device name.
Definition: xsigo.c:83
An Infiniband device.
Definition: infiniband.h:398
struct list_head nics
List of virtual Ethernet devices.
Definition: xsigo.c:101
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
#define IB_QPN_BROADCAST
Broadcast QPN.
Definition: infiniband.h:33
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
char name[16]
Device name.
Definition: xsigo.c:119
#define ETH_ALEN
Definition: if_ether.h:8
__be32 qkey
Definition: CIB_PRM.h:30
union ib_guid resource
Resource identifier.
Definition: xsigo.c:122
A Xsigo virtual Ethernet device.
Definition: xsigo.c:113
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
uint16_t pkey
Partition key.
Definition: infiniband.h:449
An Infiniband Address Vector.
Definition: infiniband.h:72
A Xsigo device.
Definition: xsigo.c:52
#define htons(value)
Definition: byteswap.h:135
void * memset(void *dest, int character, size_t len) __nonnull

References DBGC, ib_gid::dwords, ENOMEM, eoib_create(), ETH_ALEN, eth_ntoa(), free, ib_address_vector::gid, ib_address_vector::gid_present, htonl, htons, IB_GUID_ARGS, IB_GUID_FMT, IB_QPN_BROADCAST, xsigo_device::ibdev, xsigo_nic::list, list_add, list_del, mac, xsigo_nic::mac, memcpy(), memset(), xsigo_manager::name, xsigo_nic::name, name, xsigo_nic::network, xsigo_manager::nics, ib_device::pkey, qkey, ib_address_vector::qkey, ib_address_vector::qpn, rc, xsigo_nic::resource, snprintf(), strerror(), ib_gid::words, xsigo_nic::xcm, xsigo_manager::xdev, XVE_PREFIX, and zalloc().

Referenced by xsmp_rx_xve_install().

◆ xve_find()

static struct xsigo_nic* xve_find ( struct xsigo_manager xcm,
union ib_guid resource 
)
static

Find virtual Ethernet device.

Parameters
xcmConfiguration manager
resourceResource identifier
Return values
xveVirtual Ethernet device, or NULL

Definition at line 263 of file xsigo.c.

264  {
265  struct xsigo_nic *xve;
266 
267  list_for_each_entry ( xve, &xcm->nics, list ) {
268  if ( memcmp ( resource, &xve->resource,
269  sizeof ( *resource ) ) == 0 )
270  return xve;
271  }
272  return NULL;
273 }
struct list_head list
List of virtual Ethernet devices.
Definition: xsigo.c:117
struct list_head nics
List of virtual Ethernet devices.
Definition: xsigo.c:101
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
union ib_guid resource
Resource identifier.
Definition: xsigo.c:122
A Xsigo virtual Ethernet device.
Definition: xsigo.c:113
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References xsigo_nic::list, list_for_each_entry, memcmp(), xsigo_manager::nics, NULL, xsigo_nic::resource, and xsigo_nic::xcm.

Referenced by xsmp_rx_xve_delete(), xsmp_rx_xve_install(), and xsmp_rx_xve_modify().

◆ xve_destroy()

static void xve_destroy ( struct xsigo_nic xve)
static

Destroy virtual Ethernet device.

Parameters
xveVirtual Ethernet device

Definition at line 280 of file xsigo.c.

280  {
281  struct xsigo_manager *xcm = xve->xcm;
282  struct xsigo_device *xdev = xcm->xdev;
283  struct ib_device *ibdev = xdev->ibdev;
284  struct eoib_device *eoib;
285 
286  /* Destroy corresponding EoIB device, if any */
287  if ( ( eoib = eoib_find ( ibdev, xve->mac ) ) )
288  eoib_destroy ( eoib );
289 
290  /* Remove from list of virtual Ethernet devices */
291  list_del ( &xve->list );
292 
293  /* Free virtual Ethernet device */
294  DBGC ( xve, "XVE %s destroyed\n", xve->name );
295  free ( xve );
296 }
struct list_head list
List of virtual Ethernet devices.
Definition: xsigo.c:117
uint8_t mac[ETH_ALEN]
MAC address.
Definition: xsigo.c:124
void eoib_destroy(struct eoib_device *eoib)
Remove EoIB device.
Definition: eoib.c:695
An EoIB device.
Definition: eoib.h:30
#define DBGC(...)
Definition: compiler.h:505
An Infiniband device.
Definition: infiniband.h:398
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
A Xsigo configuration manager.
Definition: xsigo.c:75
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:54
char name[16]
Device name.
Definition: xsigo.c:119
struct eoib_device * eoib_find(struct ib_device *ibdev, const uint8_t *hw_addr)
Find EoIB device.
Definition: eoib.c:677
A Xsigo device.
Definition: xsigo.c:52

References DBGC, eoib_destroy(), eoib_find(), free, eoib_device::ibdev, xsigo_device::ibdev, xsigo_nic::list, list_del, xsigo_nic::mac, xsigo_nic::name, xsigo_nic::xcm, and xsigo_manager::xdev.

Referenced by xcm_destroy(), and xsmp_rx_xve_delete().

◆ xve_update_mtu()

static int xve_update_mtu ( struct xsigo_nic xve,
struct eoib_device eoib,
size_t  mtu 
)
static

Update virtual Ethernet device MTU.

Parameters
xveVirtual Ethernet device
eoibEoIB device
mtuNew MTU (excluding Ethernet and EoIB headers)
Return values
rcReturn status code

Definition at line 306 of file xsigo.c.

307  {
308  struct net_device *netdev = eoib->netdev;
309  size_t max;
310 
311  /* Check that we can support this MTU */
312  max = ( IB_MAX_PAYLOAD_SIZE - ( sizeof ( struct ethhdr ) +
313  sizeof ( struct eoib_header ) ) );
314  if ( mtu > max ) {
315  DBGC ( xve, "XVE %s cannot support MTU %zd (max %zd)\n",
316  xve->name, mtu, max );
317  return -ERANGE;
318  }
319 
320  /* Update MTU. No need to close/reopen the network device,
321  * since our Infiniband stack uses a fixed MTU anyway. Note
322  * that the network device sees the Ethernet frame header but
323  * not the EoIB header.
324  */
325  netdev->max_pkt_len = ( mtu + sizeof ( struct ethhdr ) );
326  netdev->mtu = mtu;
327  DBGC ( xve, "XVE %s has MTU %zd\n", xve->name, mtu );
328 
329  return 0;
330 }
#define max(x, y)
Definition: ath.h:39
size_t mtu
Maximum transmission unit length.
Definition: netdevice.h:415
#define DBGC(...)
Definition: compiler.h:505
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
#define ERANGE
Result too large.
Definition: errno.h:639
An EoIB header.
Definition: eoib.h:19
A network device.
Definition: netdevice.h:352
char name[16]
Device name.
Definition: xsigo.c:119
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:409
An Ethernet link-layer header.
Definition: if_ether.h:31
#define IB_MAX_PAYLOAD_SIZE
Maximum payload size.
Definition: infiniband.h:50

References DBGC, ERANGE, IB_MAX_PAYLOAD_SIZE, max, net_device::max_pkt_len, mtu, net_device::mtu, xsigo_nic::name, eoib_device::netdev, and netdev.

Referenced by xsmp_rx_xve_modify().

◆ xve_open()

static int xve_open ( struct xsigo_nic xve,
struct eoib_device eoib 
)
static

Open virtual Ethernet device.

Parameters
xveVirtual Ethernet device
eoibEoIB device
openNew administrative state
Return values
rcReturn status code

Definition at line 340 of file xsigo.c.

340  {
341  struct net_device *netdev = eoib->netdev;
342  int rc;
343 
344  /* Do nothing if network device is already open */
345  if ( netdev_is_open ( netdev ) )
346  return 0;
347  DBGC ( xve, "XVE %s opening network device\n", xve->name );
348 
349  /* Open network device */
350  if ( ( rc = netdev_open ( netdev ) ) != 0 ) {
351  DBGC ( xve, "XVE %s could not open: %s\n",
352  xve->name, strerror ( rc ) );
353  return rc;
354  }
355 
356  return 0;
357 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define DBGC(...)
Definition: compiler.h:505
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:658
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
A network device.
Definition: netdevice.h:352
char name[16]
Device name.
Definition: xsigo.c:119
int netdev_open(struct net_device *netdev)
Open network device.
Definition: netdevice.c:861

References DBGC, xsigo_nic::name, eoib_device::netdev, netdev, netdev_is_open(), netdev_open(), rc, and strerror().

Referenced by xve_update_state().

◆ xve_close()

static void xve_close ( struct xsigo_nic xve,
struct eoib_device eoib 
)
static

Close virtual Ethernet device.

Parameters
xveVirtual Ethernet device
eoibEoIB device

Definition at line 365 of file xsigo.c.

365  {
366  struct net_device *netdev = eoib->netdev;
367 
368  /* Do nothing if network device is already closed */
369  if ( ! netdev_is_open ( netdev ) )
370  return;
371 
372  /* Close network device */
373  netdev_close ( netdev );
374  DBGC ( xve, "XVE %s closed network device\n", xve->name );
375 }
#define DBGC(...)
Definition: compiler.h:505
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:658
static struct net_device * netdev
Definition: gdbudp.c:52
struct net_device * netdev
Network device.
Definition: eoib.h:34
A network device.
Definition: netdevice.h:352
char name[16]
Device name.
Definition: xsigo.c:119
void netdev_close(struct net_device *netdev)
Close network device.
Definition: netdevice.c:895

References DBGC, xsigo_nic::name, eoib_device::netdev, netdev, netdev_close(), and netdev_is_open().

Referenced by xve_update_state().

◆ xve_update_state()

static int xve_update_state ( struct xsigo_nic xve,
struct eoib_device eoib,
int  open 
)
static

Update virtual Ethernet device administrative state.

Parameters
xveVirtual Ethernet device
eoibEoIB device
openNew administrative state
Return values
rcReturn status code

Definition at line 385 of file xsigo.c.

386  {
387 
388  /* Open or close device, as applicable */
389  if ( open ) {
390  return xve_open ( xve, eoib );
391  } else {
392  xve_close ( xve, eoib );
393  return 0;
394  }
395 }
static void xve_close(struct xsigo_nic *xve, struct eoib_device *eoib)
Close virtual Ethernet device.
Definition: xsigo.c:365
static int xve_open(struct xsigo_nic *xve, struct eoib_device *eoib)
Open virtual Ethernet device.
Definition: xsigo.c:340
int open(const char *uri_string)
Open file.
Definition: posix_io.c:176

References open(), xve_close(), and xve_open().

Referenced by xsmp_rx_xve_modify().

◆ xve_update_tca()

static int xve_update_tca ( struct xsigo_nic xve,
struct eoib_device eoib,
struct ib_address_vector av 
)
static

Update gateway (TCA)

Parameters
xveVirtual Ethernet device
eoibEoIB device
avAddress vector, or NULL if no gateway
Return values
rcReturn status code

Definition at line 405 of file xsigo.c.

406  {
407 
408  /* Update gateway address */
409  eoib_set_gateway ( eoib, av );
410  if ( av ) {
411  DBGC ( xve, "XVE %s has TCA " IB_GID_FMT " data %#lx qkey "
412  "%#lx\n", xve->name, IB_GID_ARGS ( &av->gid ), av->qpn,
413  av->qkey );
414  } else {
415  DBGC ( xve, "XVE %s has no TCA\n", xve->name );
416  }
417 
418  /* The Linux driver will modify the local device's link state
419  * to reflect the EoIB-to-Ethernet gateway's link state, but
420  * this seems philosophically incorrect since communication
421  * within the EoIB broadcast domain still works regardless of
422  * the state of the gateway.
423  */
424 
425  return 0;
426 }
void eoib_set_gateway(struct eoib_device *eoib, struct ib_address_vector *av)
Set EoIB gateway.
Definition: eoib.c:881
#define DBGC(...)
Definition: compiler.h:505
unsigned long qkey
Queue key.
Definition: infiniband.h:79
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
char name[16]
Device name.
Definition: xsigo.c:119
unsigned long qpn
Queue Pair Number.
Definition: infiniband.h:74
union ib_gid gid
GID, if present.
Definition: infiniband.h:92
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45

References DBGC, eoib_set_gateway(), ib_address_vector::gid, IB_GID_ARGS, IB_GID_FMT, xsigo_nic::name, ib_address_vector::qkey, and ib_address_vector::qpn.

Referenced by xsmp_rx_xve_modify().

◆ xsmp_session_type()

static const char* xsmp_session_type ( unsigned int  type)
static

Get session message name (for debugging)

Parameters
typeMessage type
Return values
nameMessage name

Definition at line 441 of file xsigo.c.

441  {
442  static char buf[16];
443 
444  switch ( type ) {
445  case XSMP_SESSION_TYPE_HELLO: return "HELLO";
446  case XSMP_SESSION_TYPE_REGISTER: return "REGISTER";
447  case XSMP_SESSION_TYPE_CONFIRM: return "CONFIRM";
448  case XSMP_SESSION_TYPE_REJECT: return "REJECT";
449  case XSMP_SESSION_TYPE_SHUTDOWN: return "SHUTDOWN";
450  default:
451  snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", type );
452  return buf;
453  }
454 }
Shutdown message.
Definition: xsigo.h:213
Keepalive message.
Definition: xsigo.h:205
Registration rejection message.
Definition: xsigo.h:211
Registration confirmation message.
Definition: xsigo.h:209
Initial registration message.
Definition: xsigo.h:207
uint32_t type
Operating system type.
Definition: ena.h:12
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382

References snprintf(), type, XSMP_SESSION_TYPE_CONFIRM, XSMP_SESSION_TYPE_HELLO, XSMP_SESSION_TYPE_REGISTER, XSMP_SESSION_TYPE_REJECT, and XSMP_SESSION_TYPE_SHUTDOWN.

◆ xsmp_chassis_name()

static const char* xsmp_chassis_name ( struct xsmp_session_message msg)
static

Extract chassis name (for debugging)

Parameters
msgSession message
Return values
chassisChassis name

Definition at line 462 of file xsigo.c.

462  {
463  static char chassis[ sizeof ( msg->chassis ) + 1 /* NUL */ ];
464 
465  memcpy ( chassis, msg->chassis, sizeof ( msg->chassis ) );
466  return chassis;
467 }
void * memcpy(void *dest, const void *src, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References memcpy(), and msg().

Referenced by xsmp_rx_session_confirm(), xsmp_rx_session_reject(), and xsmp_rx_session_shutdown().

◆ xsmp_session_name()

static const char* xsmp_session_name ( struct xsmp_session_message msg)
static

Extract session name (for debugging)

Parameters
msgSession message
Return values
sessionSession name

Definition at line 475 of file xsigo.c.

475  {
476  static char session[ sizeof ( msg->session ) + 1 /* NUL */ ];
477 
478  memcpy ( session, msg->session, sizeof ( msg->session ) );
479  return session;
480 }
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct ntlm_data session
Session key.
Definition: ntlm.h:24
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References memcpy(), msg(), and session.

Referenced by xsmp_rx_session_confirm().

◆ xsmp_tx_session()

static int xsmp_tx_session ( struct xsigo_manager xcm,
unsigned int  type 
)
static

Send session message.

Parameters
xcmConfiguration manager
typeMessage type
Return values
rcReturn status code

Definition at line 489 of file xsigo.c.

489  {
490  struct xsigo_device *xdev = xcm->xdev;
491  struct ib_device *ibdev = xdev->ibdev;
492  struct xsmp_session_message msg;
493  int rc;
494 
495  /* Construct session message */
496  memset ( &msg, 0, sizeof ( msg ) );
497  msg.hdr.type = XSMP_TYPE_SESSION;
498  msg.hdr.len = htons ( sizeof ( msg ) );
499  msg.hdr.seq = htonl ( ++xcm->seq );
500  memcpy ( &msg.hdr.src.guid, &ibdev->gid.s.guid,
501  sizeof ( msg.hdr.src.guid ) );
502  memcpy ( &msg.hdr.dst.guid, &xcm->id.guid,
503  sizeof ( msg.hdr.dst.guid ) );
504  msg.type = type;
505  msg.len = htons ( sizeof ( msg ) - sizeof ( msg.hdr ) );
506  msg.os_type = XSIGO_OS_TYPE_GENERIC;
507  msg.resources = htons ( XSIGO_RESOURCE_XVE |
509  msg.boot = htonl ( XSMP_BOOT_PXE );
510  DBGCP ( xcm, "XCM %s TX[%d] session %s\n", xcm->name,
511  ntohl ( msg.hdr.seq ), xsmp_session_type ( msg.type ) );
512  DBGCP_HDA ( xcm, 0, &msg, sizeof ( msg ) );
513 
514  /* Send session message */
515  if ( ( rc = xfer_deliver_raw ( &xcm->xfer, &msg,
516  sizeof ( msg ) ) ) != 0 ) {
517  DBGC ( xcm, "XCM %s TX session %s failed: %s\n", xcm->name,
518  xsmp_session_type ( msg.type ), strerror ( rc ) );
519  return rc;
520  }
521 
522  return 0;
523 }
An XSMP session message.
Definition: xsigo.h:165
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Virtual Ethernet resource type.
Definition: xsigo.h:40
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
#define DBGC(...)
Definition: compiler.h:505
#define ntohl(value)
Definition: byteswap.h:134
#define htonl(value)
Definition: byteswap.h:133
Session message type.
Definition: xsigo.h:159
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:288
char name[16]
Device name.
Definition: xsigo.c:83
An Infiniband device.
Definition: infiniband.h:398
#define DBGCP_HDA(...)
Definition: compiler.h:540
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct xsigo_manager_id id
Manager ID.
Definition: xsigo.c:85
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct ib_gid::@559 s
union ib_guid guid
Port GUID.
Definition: xsigo.h:56
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint32_t seq
Transmit sequence number.
Definition: xsigo.c:98
xsmp_session_type
XSMP session message types.
Definition: xsigo.h:203
Absence-of-high-availability "resource" type.
Definition: xsigo.h:42
PXE boot.
Definition: xsigo.h:219
uint32_t type
Operating system type.
Definition: ena.h:12
#define DBGCP(...)
Definition: compiler.h:539
#define XSIGO_OS_TYPE_GENERIC
Generic operating system type.
Definition: xsigo.h:32
A Xsigo device.
Definition: xsigo.c:52
#define htons(value)
Definition: byteswap.h:135
void * memset(void *dest, int character, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, DBGCP, DBGCP_HDA, ib_device::gid, ib_gid::guid, xsigo_manager_id::guid, htonl, htons, xsigo_device::ibdev, xsigo_manager::id, memcpy(), memset(), msg(), xsigo_manager::name, ntohl, rc, ib_gid::s, xsigo_manager::seq, strerror(), type, xsigo_manager::xdev, xsigo_manager::xfer, xfer_deliver_raw(), XSIGO_OS_TYPE_GENERIC, XSIGO_RESOURCE_NO_HA, XSIGO_RESOURCE_XVE, XSMP_BOOT_PXE, and XSMP_TYPE_SESSION.

Referenced by xsmp_tx_session_hello(), and xsmp_tx_session_register().

◆ xsmp_tx_session_register()

static int xsmp_tx_session_register ( struct xsigo_manager xcm)
inlinestatic

Send registration message.

Parameters
xcmConfiguration manager
Return values
rcReturn status code

Definition at line 531 of file xsigo.c.

531  {
532 
533  DBGC ( xcm, "XCM %s registering with " IB_GUID_FMT "\n",
534  xcm->name, IB_GUID_ARGS ( &xcm->id.guid ) );
535 
536  /* Send registration message */
538 }
#define DBGC(...)
Definition: compiler.h:505
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
static int xsmp_tx_session(struct xsigo_manager *xcm, unsigned int type)
Send session message.
Definition: xsigo.c:489
char name[16]
Device name.
Definition: xsigo.c:83
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
struct xsigo_manager_id id
Manager ID.
Definition: xsigo.c:85
union ib_guid guid
Port GUID.
Definition: xsigo.h:56
Initial registration message.
Definition: xsigo.h:207

References DBGC, xsigo_manager_id::guid, IB_GUID_ARGS, IB_GUID_FMT, xsigo_manager::id, xsigo_manager::name, XSMP_SESSION_TYPE_REGISTER, and xsmp_tx_session().

Referenced by xcm_step().

◆ xsmp_tx_session_hello()

static int xsmp_tx_session_hello ( struct xsigo_manager xcm)
static

Send keepalive message.

Parameters
xcmConfiguration manager
Return values
rcReturn status code

Definition at line 546 of file xsigo.c.

546  {
547 
548  /* Send keepalive message */
550 }
Keepalive message.
Definition: xsigo.h:205
static int xsmp_tx_session(struct xsigo_manager *xcm, unsigned int type)
Send session message.
Definition: xsigo.c:489

References XSMP_SESSION_TYPE_HELLO, and xsmp_tx_session().

Referenced by xcm_keepalive(), and xsmp_rx_session_hello().

◆ xsmp_rx_session_hello()

static int xsmp_rx_session_hello ( struct xsigo_manager xcm,
struct xsmp_session_message *msg  __unused 
)
static

Handle received keepalive message.

Parameters
xcmConfiguration manager
msgKeepalive message
Return values
rcReturn status code

Definition at line 559 of file xsigo.c.

560  {
561 
562  /* Respond to keepalive message. Note that the XCM doesn't
563  * seem to actually ever send these.
564  */
565  return xsmp_tx_session_hello ( xcm );
566 }
static int xsmp_tx_session_hello(struct xsigo_manager *xcm)
Send keepalive message.
Definition: xsigo.c:546

References xsmp_tx_session_hello().

Referenced by xsmp_rx_session().

◆ xsmp_rx_session_confirm()

static int xsmp_rx_session_confirm ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
)
static

Handle received registration confirmation message.

Parameters
xcmConfiguration manager
msgRegistration confirmation message
Return values
rcReturn status code

Definition at line 575 of file xsigo.c.

576  {
577 
578  DBGC ( xcm, "XCM %s registered with \"%s\" as \"%s\"\n", xcm->name,
580 
581  return 0;
582 }
#define DBGC(...)
Definition: compiler.h:505
char name[16]
Device name.
Definition: xsigo.c:83
static const char * xsmp_session_name(struct xsmp_session_message *msg)
Extract session name (for debugging)
Definition: xsigo.c:475
static const char * xsmp_chassis_name(struct xsmp_session_message *msg)
Extract chassis name (for debugging)
Definition: xsigo.c:462
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, msg(), xsigo_manager::name, xsmp_chassis_name(), and xsmp_session_name().

Referenced by xsmp_rx_session().

◆ xsmp_rx_session_reject()

static int xsmp_rx_session_reject ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
)
static

Handle received registration rejection message.

Parameters
xcmConfiguration manager
msgRegistration confirmation message
Return values
rcReturn status code

Definition at line 591 of file xsigo.c.

592  {
593 
594  DBGC ( xcm, "XCM %s rejected by \"%s\":\n",
595  xcm->name, xsmp_chassis_name ( msg ) );
596  DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );
597 
598  return -EPERM;
599 }
#define DBGC(...)
Definition: compiler.h:505
char name[16]
Device name.
Definition: xsigo.c:83
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPERM
Operation not permitted.
Definition: errno.h:614
static const char * xsmp_chassis_name(struct xsmp_session_message *msg)
Extract chassis name (for debugging)
Definition: xsigo.c:462
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, DBGC_HDA, EPERM, msg(), xsigo_manager::name, and xsmp_chassis_name().

Referenced by xsmp_rx_session().

◆ xsmp_rx_session_shutdown()

static int xsmp_rx_session_shutdown ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
)
static

Handle received shutdown message.

Parameters
xcmConfiguration manager
msgRegistration confirmation message
Return values
rcReturn status code

Definition at line 608 of file xsigo.c.

609  {
610 
611  DBGC ( xcm, "XCM %s shut down by \"%s\":\n",
612  xcm->name, xsmp_chassis_name ( msg ) );
613  DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );
614 
615  return -ENOTCONN;
616 }
#define DBGC(...)
Definition: compiler.h:505
char name[16]
Device name.
Definition: xsigo.c:83
#define DBGC_HDA(...)
Definition: compiler.h:506
#define ENOTCONN
The socket is not connected.
Definition: errno.h:569
static const char * xsmp_chassis_name(struct xsmp_session_message *msg)
Extract chassis name (for debugging)
Definition: xsigo.c:462
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, DBGC_HDA, ENOTCONN, msg(), xsigo_manager::name, and xsmp_chassis_name().

Referenced by xsmp_rx_session().

◆ xsmp_rx_session()

static int xsmp_rx_session ( struct xsigo_manager xcm,
struct xsmp_session_message msg 
)
static

Handle received session message.

Parameters
xcmConfiguration manager
msgSession message
Return values
rcReturn status code

Definition at line 625 of file xsigo.c.

626  {
627 
628  DBGCP ( xcm, "XCM %s RX[%d] session %s\n", xcm->name,
629  ntohl ( msg->hdr.seq ), xsmp_session_type ( msg->type ) );
630  DBGCP_HDA ( xcm, 0, msg, sizeof ( *msg ) );
631 
632  /* Handle message according to type */
633  switch ( msg->type ) {
635  return xsmp_rx_session_hello ( xcm, msg );
637  return xsmp_rx_session_confirm ( xcm, msg );
639  return xsmp_rx_session_reject ( xcm, msg );
641  return xsmp_rx_session_shutdown ( xcm, msg );
642  default:
643  DBGC ( xcm, "XCM %s RX[%d] session unexpected %s:\n", xcm->name,
644  ntohl ( msg->hdr.seq ), xsmp_session_type ( msg->type ));
645  DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );
646  return -EPROTO;
647  }
648 }
static int xsmp_rx_session_hello(struct xsigo_manager *xcm, struct xsmp_session_message *msg __unused)
Handle received keepalive message.
Definition: xsigo.c:559
Shutdown message.
Definition: xsigo.h:213
#define DBGC(...)
Definition: compiler.h:505
static int xsmp_rx_session_shutdown(struct xsigo_manager *xcm, struct xsmp_session_message *msg)
Handle received shutdown message.
Definition: xsigo.c:608
Keepalive message.
Definition: xsigo.h:205
#define ntohl(value)
Definition: byteswap.h:134
char name[16]
Device name.
Definition: xsigo.c:83
#define DBGCP_HDA(...)
Definition: compiler.h:540
#define DBGC_HDA(...)
Definition: compiler.h:506
static int xsmp_rx_session_confirm(struct xsigo_manager *xcm, struct xsmp_session_message *msg)
Handle received registration confirmation message.
Definition: xsigo.c:575
#define EPROTO
Protocol error.
Definition: errno.h:624
Registration rejection message.
Definition: xsigo.h:211
xsmp_session_type
XSMP session message types.
Definition: xsigo.h:203
Registration confirmation message.
Definition: xsigo.h:209
#define DBGCP(...)
Definition: compiler.h:539
static int xsmp_rx_session_reject(struct xsigo_manager *xcm, struct xsmp_session_message *msg)
Handle received registration rejection message.
Definition: xsigo.c:591
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, DBGC_HDA, DBGCP, DBGCP_HDA, EPROTO, msg(), xsigo_manager::name, ntohl, xsmp_rx_session_confirm(), xsmp_rx_session_hello(), xsmp_rx_session_reject(), xsmp_rx_session_shutdown(), XSMP_SESSION_TYPE_CONFIRM, XSMP_SESSION_TYPE_HELLO, XSMP_SESSION_TYPE_REJECT, and XSMP_SESSION_TYPE_SHUTDOWN.

Referenced by xcm_deliver().

◆ xsmp_xve_type()

static const char* xsmp_xve_type ( unsigned int  type)
static

Get virtual Ethernet message name (for debugging)

Parameters
typeMessage type
Return values
nameMessage name

Definition at line 663 of file xsigo.c.

663  {
664  static char buf[16];
665 
666  switch ( type ) {
667  case XSMP_XVE_TYPE_INSTALL: return "INSTALL";
668  case XSMP_XVE_TYPE_DELETE: return "DELETE";
669  case XSMP_XVE_TYPE_UPDATE: return "UPDATE";
670  case XSMP_XVE_TYPE_OPER_UP: return "OPER_UP";
671  case XSMP_XVE_TYPE_OPER_DOWN: return "OPER_DOWN";
672  case XSMP_XVE_TYPE_OPER_REQ: return "OPER_REQ";
673  case XSMP_XVE_TYPE_READY: return "READY";
674  default:
675  snprintf ( buf, sizeof ( buf ), "UNKNOWN<%d>", type );
676  return buf;
677  }
678 }
Install virtual NIC.
Definition: xsigo.h:317
Set operational state up.
Definition: xsigo.h:323
Get operational state.
Definition: xsigo.h:327
Update virtual NIC.
Definition: xsigo.h:321
Set operational state down.
Definition: xsigo.h:325
uint32_t type
Operating system type.
Definition: ena.h:12
Delete virtual NIC.
Definition: xsigo.h:319
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
Virtual NIC is ready.
Definition: xsigo.h:329

References snprintf(), type, XSMP_XVE_TYPE_DELETE, XSMP_XVE_TYPE_INSTALL, XSMP_XVE_TYPE_OPER_DOWN, XSMP_XVE_TYPE_OPER_REQ, XSMP_XVE_TYPE_OPER_UP, XSMP_XVE_TYPE_READY, and XSMP_XVE_TYPE_UPDATE.

◆ xsmp_tx_xve()

static int xsmp_tx_xve ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
static

Send virtual Ethernet message.

Parameters
xcmConfiguration manager
msgPartial message
Return values
rcReturn status code

Definition at line 687 of file xsigo.c.

688  {
689  struct xsigo_device *xdev = xcm->xdev;
690  struct ib_device *ibdev = xdev->ibdev;
691  int rc;
692 
693  /* Fill in common header fields */
694  msg->hdr.type = XSMP_TYPE_XVE;
695  msg->hdr.len = htons ( sizeof ( *msg ) );
696  msg->hdr.seq = htonl ( ++xcm->seq );
697  memcpy ( &msg->hdr.src.guid, &ibdev->gid.s.guid,
698  sizeof ( msg->hdr.src.guid ) );
699  memcpy ( &msg->hdr.dst.guid, &xcm->id.guid,
700  sizeof ( msg->hdr.dst.guid ) );
701  msg->len = htons ( sizeof ( *msg ) - sizeof ( msg->hdr ) );
702  DBGCP ( xcm, "XCM %s TX[%d] xve %s code %#02x\n", xcm->name,
703  ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ),
704  msg->code );
705  DBGCP_HDA ( xcm, 0, msg, sizeof ( *msg ) );
706 
707  /* Send virtual Ethernet message */
708  if ( ( rc = xfer_deliver_raw ( &xcm->xfer, msg,
709  sizeof ( *msg ) ) ) != 0 ) {
710  DBGC ( xcm, "XCM %s TX xve %s failed: %s\n", xcm->name,
711  xsmp_xve_type ( msg->type ), strerror ( rc ) );
712  return rc;
713  }
714 
715  return 0;
716 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
#define DBGC(...)
Definition: compiler.h:505
#define ntohl(value)
Definition: byteswap.h:134
xsmp_xve_type
XSMP virtual Ethernet message types.
Definition: xsigo.h:315
Virtual Ethernet message type.
Definition: xsigo.h:161
#define htonl(value)
Definition: byteswap.h:133
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:288
char name[16]
Device name.
Definition: xsigo.c:83
An Infiniband device.
Definition: infiniband.h:398
#define DBGCP_HDA(...)
Definition: compiler.h:540
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct xsigo_manager_id id
Manager ID.
Definition: xsigo.c:85
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct ib_gid::@559 s
union ib_guid guid
Port GUID.
Definition: xsigo.h:56
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint32_t seq
Transmit sequence number.
Definition: xsigo.c:98
#define DBGCP(...)
Definition: compiler.h:539
A Xsigo device.
Definition: xsigo.c:52
#define htons(value)
Definition: byteswap.h:135
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, DBGCP, DBGCP_HDA, ib_device::gid, ib_gid::guid, xsigo_manager_id::guid, htonl, htons, xsigo_device::ibdev, xsigo_manager::id, memcpy(), msg(), xsigo_manager::name, ntohl, rc, ib_gid::s, xsigo_manager::seq, strerror(), xsigo_manager::xdev, xsigo_manager::xfer, xfer_deliver_raw(), and XSMP_TYPE_XVE.

Referenced by xsmp_rx_xve_delete(), xsmp_tx_xve_nack(), and xsmp_tx_xve_params().

◆ xsmp_tx_xve_params()

static int xsmp_tx_xve_params ( struct xsigo_manager xcm,
struct xsmp_xve_message msg,
struct xsigo_nic xve,
struct eoib_device eoib 
)
static

Send virtual Ethernet message including current device parameters.

Parameters
xcmConfiguration manager
msgPartial virtual Ethernet message
xveVirtual Ethernet device
eoibEoIB device
Return values
rcReturn status code

Definition at line 727 of file xsigo.c.

730  {
731  struct xsigo_device *xdev = xcm->xdev;
732  struct ib_device *ibdev = xdev->ibdev;
733  struct net_device *netdev = eoib->netdev;
734 
735  /* Set successful response code */
736  msg->code = 0;
737 
738  /* Include network identifier, MTU, and current HCA parameters */
739  msg->network = htonl ( xve->network );
740  msg->mtu = htons ( netdev->max_pkt_len - sizeof ( struct ethhdr ) );
741  msg->hca.prefix_le.qword = bswap_64 ( ibdev->gid.s.prefix.qword );
742  msg->hca.pkey = htons ( ibdev->pkey );
743  msg->hca.qkey = msg->tca.qkey;
744  if ( eoib->qp ) {
745  msg->hca.data = htonl ( eoib->qp->ext_qpn );
746  msg->hca.qkey = htons ( eoib->qp->qkey );
747  }
748 
749  /* The message type field is (ab)used to return the current
750  * operational status.
751  */
752  if ( msg->type == XSMP_XVE_TYPE_OPER_REQ ) {
753  msg->type = ( netdev_is_open ( netdev ) ?
755  }
756 
757  /* Send message */
758  DBGC ( xve, "XVE %s network %d MTU %d ctrl %#x data %#x qkey %#04x "
759  "%s\n", xve->name, ntohl ( msg->network ), ntohs ( msg->mtu ),
760  ntohl ( msg->hca.ctrl ), ntohl ( msg->hca.data ),
761  ntohs ( msg->hca.qkey ), xsmp_xve_type ( msg->type ) );
762 
763  return xsmp_tx_xve ( xcm, msg );
764 }
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
unsigned long network
Network ID.
Definition: xsigo.c:126
#define DBGC(...)
Definition: compiler.h:505
#define ntohl(value)
Definition: byteswap.h:134
static int xsmp_tx_xve(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Send virtual Ethernet message.
Definition: xsigo.c:687
#define ntohs(value)
Definition: byteswap.h:136
xsmp_xve_type
XSMP virtual Ethernet message types.
Definition: xsigo.h:315
#define htonl(value)
Definition: byteswap.h:133
unsigned long qkey
Queue key.
Definition: infiniband.h:176
An Infiniband device.
Definition: infiniband.h:398
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
static int netdev_is_open(struct net_device *netdev)
Check whether or not network device is open.
Definition: netdevice.h:658
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
unsigned long ext_qpn
Externally-visible queue pair number.
Definition: infiniband.h:172
static struct net_device * netdev
Definition: gdbudp.c:52
struct ib_gid::@559 s
struct net_device * netdev
Network device.
Definition: eoib.h:34
uint64_t qword
Definition: ib_packet.h:22
union ib_guid prefix
Definition: ib_packet.h:39
A network device.
Definition: netdevice.h:352
char name[16]
Device name.
Definition: xsigo.c:119
Set operational state up.
Definition: xsigo.h:323
Get operational state.
Definition: xsigo.h:327
Set operational state down.
Definition: xsigo.h:325
#define bswap_64(value)
Definition: byteswap.h:82
uint16_t pkey
Partition key.
Definition: infiniband.h:449
A Xsigo device.
Definition: xsigo.c:52
struct ib_queue_pair * qp
Queue pair.
Definition: eoib.h:45
size_t max_pkt_len
Maximum packet length.
Definition: netdevice.h:409
An Ethernet link-layer header.
Definition: if_ether.h:31
#define htons(value)
Definition: byteswap.h:135
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References bswap_64, DBGC, ib_queue_pair::ext_qpn, ib_device::gid, htonl, htons, xsigo_device::ibdev, net_device::max_pkt_len, msg(), xsigo_nic::name, eoib_device::netdev, netdev, netdev_is_open(), xsigo_nic::network, ntohl, ntohs, ib_device::pkey, ib_gid::prefix, ib_queue_pair::qkey, eoib_device::qp, ib_guid::qword, ib_gid::s, xsigo_manager::xdev, xsmp_tx_xve(), XSMP_XVE_TYPE_OPER_DOWN, XSMP_XVE_TYPE_OPER_REQ, and XSMP_XVE_TYPE_OPER_UP.

Referenced by xsmp_rx_xve_modify(), and xsmp_tx_xve_notify().

◆ xsmp_tx_xve_nack()

static int xsmp_tx_xve_nack ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
inlinestatic

Send virtual Ethernet error response.

Parameters
xcmConfiguration manager
msgPartial virtual Ethernet message
Return values
rcReturn status code

Definition at line 773 of file xsigo.c.

774  {
775 
776  /* Set error response code. (There aren't any meaningful
777  * detailed response codes defined by the wire protocol.)
778  */
779  msg->code = XSMP_XVE_CODE_ERROR;
780 
781  /* Send message */
782  return xsmp_tx_xve ( xcm, msg );
783 }
static int xsmp_tx_xve(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Send virtual Ethernet message.
Definition: xsigo.c:687
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References msg(), xsmp_tx_xve(), and XSMP_XVE_CODE_ERROR.

Referenced by xsmp_rx_xve_install(), and xsmp_rx_xve_modify().

◆ xsmp_tx_xve_notify()

static int xsmp_tx_xve_notify ( struct xsigo_manager xcm,
unsigned int  type,
struct xsigo_nic xve,
struct eoib_device eoib 
)
static

Send virtual Ethernet notification.

Parameters
xcmConfiguration manager
typeMessage type
xveVirtual Ethernet device
eoibEoIB device
Return values
rcReturn status code

Definition at line 794 of file xsigo.c.

797  {
798  struct xsmp_xve_message msg;
799 
800  /* Construct message */
801  memset ( &msg, 0, sizeof ( msg ) );
802  msg.type = type;
803  memcpy ( &msg.resource, &xve->resource, sizeof ( msg.resource ) );
804 
805  /* Send message */
806  return xsmp_tx_xve_params ( xcm, &msg, xve, eoib );
807 }
void * memcpy(void *dest, const void *src, size_t len) __nonnull
An XSMP virtual Ethernet message.
Definition: xsigo.h:245
static int xsmp_tx_xve_params(struct xsigo_manager *xcm, struct xsmp_xve_message *msg, struct xsigo_nic *xve, struct eoib_device *eoib)
Send virtual Ethernet message including current device parameters.
Definition: xsigo.c:727
union ib_guid resource
Resource identifier.
Definition: xsigo.c:122
uint32_t type
Operating system type.
Definition: ena.h:12
void * memset(void *dest, int character, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References memcpy(), memset(), msg(), xsigo_nic::resource, type, and xsmp_tx_xve_params().

Referenced by xsmp_tx_xve_oper().

◆ xsmp_tx_xve_oper()

static int xsmp_tx_xve_oper ( struct xsigo_manager xcm,
struct xsigo_nic xve,
struct eoib_device eoib 
)
inlinestatic

Send virtual Ethernet current operational state.

Parameters
xcmConfiguration manager
xveVirtual Ethernet device
eoibEoIB device
Return values
rcReturn status code

Definition at line 817 of file xsigo.c.

819  {
820 
821  /* Send notification */
822  return xsmp_tx_xve_notify ( xcm, XSMP_XVE_TYPE_OPER_REQ, xve, eoib );
823 }
static int xsmp_tx_xve_notify(struct xsigo_manager *xcm, unsigned int type, struct xsigo_nic *xve, struct eoib_device *eoib)
Send virtual Ethernet notification.
Definition: xsigo.c:794
Get operational state.
Definition: xsigo.h:327

References xsmp_tx_xve_notify(), and XSMP_XVE_TYPE_OPER_REQ.

Referenced by xsigo_net_notify().

◆ xsmp_rx_xve_modify()

static int xsmp_rx_xve_modify ( struct xsigo_manager xcm,
struct xsmp_xve_message msg,
unsigned int  update 
)
static

Handle received virtual Ethernet modification message.

Parameters
xcmConfiguration manager
msgVirtual Ethernet message
updateUpdate bitmask
Return values
rcReturn status code

Definition at line 833 of file xsigo.c.

835  {
836  struct xsigo_device *xdev = xcm->xdev;
837  struct ib_device *ibdev = xdev->ibdev;
838  struct xsigo_nic *xve;
839  struct eoib_device *eoib;
840  struct ib_address_vector tca;
841  size_t mtu;
842  int rc;
843 
844  /* Avoid returning uninitialised HCA parameters in response */
845  memset ( &msg->hca, 0, sizeof ( msg->hca ) );
846 
847  /* Find virtual Ethernet device */
848  xve = xve_find ( xcm, &msg->resource );
849  if ( ! xve ) {
850  DBGC ( xcm, "XCM %s unrecognised resource " IB_GUID_FMT "\n",
851  xcm->name, IB_GUID_ARGS ( &msg->resource ) );
852  rc = -ENOENT;
853  goto err_no_xve;
854  }
855 
856  /* Find corresponding EoIB device */
857  eoib = eoib_find ( ibdev, xve->mac );
858  if ( ! eoib ) {
859  DBGC ( xve, "XVE %s has no EoIB device\n", xve->name );
860  rc = -EPIPE;
861  goto err_no_eoib;
862  }
863 
864  /* The Xsigo management software fails to create the EoIB
865  * multicast group. This is a fundamental design flaw.
866  */
867  eoib_force_group_creation ( eoib );
868 
869  /* Extract modifiable parameters. Note that the TCA GID is
870  * erroneously transmitted as little-endian.
871  */
872  mtu = ntohs ( msg->mtu );
873  memset ( &tca, 0, sizeof ( tca ) );
874  tca.qpn = ntohl ( msg->tca.data );
875  tca.qkey = ntohs ( msg->tca.qkey );
876  tca.gid_present = 1;
877  tca.gid.s.prefix.qword = bswap_64 ( msg->tca.prefix_le.qword );
878  tca.gid.s.guid.qword = bswap_64 ( msg->guid_le.qword );
879 
880  /* Update MTU, if applicable */
881  if ( ( update & XSMP_XVE_UPDATE_MTU ) &&
882  ( ( rc = xve_update_mtu ( xve, eoib, mtu ) ) != 0 ) )
883  goto err_mtu;
884  update &= ~XSMP_XVE_UPDATE_MTU;
885 
886  /* Update admin state, if applicable */
887  if ( ( update & XSMP_XVE_UPDATE_STATE ) &&
888  ( ( rc = xve_update_state ( xve, eoib, msg->state ) ) != 0 ) )
889  goto err_state;
890  update &= ~XSMP_XVE_UPDATE_STATE;
891 
892  /* Remove gateway, if applicable */
893  if ( ( update & XSMP_XVE_UPDATE_GW_DOWN ) &&
894  ( ( rc = xve_update_tca ( xve, eoib, NULL ) ) != 0 ) )
895  goto err_gw_down;
896  update &= ~XSMP_XVE_UPDATE_GW_DOWN;
897 
898  /* Update gateway, if applicable */
899  if ( ( update & XSMP_XVE_UPDATE_GW_CHANGE ) &&
900  ( ( rc = xve_update_tca ( xve, eoib, &tca ) ) != 0 ) )
901  goto err_gw_change;
902  update &= ~XSMP_XVE_UPDATE_GW_CHANGE;
903 
904  /* Warn about unexpected updates */
905  if ( update ) {
906  DBGC ( xve, "XVE %s unrecognised update(s) %#08x\n",
907  xve->name, update );
908  }
909 
910  xsmp_tx_xve_params ( xcm, msg, xve, eoib );
911  return 0;
912 
913  err_gw_change:
914  err_gw_down:
915  err_state:
916  err_mtu:
917  err_no_eoib:
918  err_no_xve:
919  /* Send NACK */
920  xsmp_tx_xve_nack ( xcm, msg );
921  return rc;
922 }
static int xve_update_mtu(struct xsigo_nic *xve, struct eoib_device *eoib, size_t mtu)
Update virtual Ethernet device MTU.
Definition: xsigo.c:306
uint8_t mac[ETH_ALEN]
MAC address.
Definition: xsigo.c:124
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Update administrative state.
Definition: xsigo.h:343
An EoIB device.
Definition: eoib.h:30
#define EPIPE
Broken pipe.
Definition: errno.h:619
#define DBGC(...)
Definition: compiler.h:505
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
#define ENOENT
No such file or directory.
Definition: errno.h:514
#define ntohl(value)
Definition: byteswap.h:134
#define ntohs(value)
Definition: byteswap.h:136
char name[16]
Device name.
Definition: xsigo.c:83
An Infiniband device.
Definition: infiniband.h:398
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
Update gateway to mark as down.
Definition: xsigo.h:345
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
static int xve_update_tca(struct xsigo_nic *xve, struct eoib_device *eoib, struct ib_address_vector *av)
Update gateway (TCA)
Definition: xsigo.c:405
static void eoib_force_group_creation(struct eoib_device *eoib)
Force creation of multicast group.
Definition: eoib.h:81
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
char name[16]
Device name.
Definition: xsigo.c:119
Update MTU.
Definition: xsigo.h:341
static struct xsigo_nic * xve_find(struct xsigo_manager *xcm, union ib_guid *resource)
Find virtual Ethernet device.
Definition: xsigo.c:263
static int xsmp_tx_xve_params(struct xsigo_manager *xcm, struct xsmp_xve_message *msg, struct xsigo_nic *xve, struct eoib_device *eoib)
Send virtual Ethernet message including current device parameters.
Definition: xsigo.c:727
struct eoib_device * eoib_find(struct ib_device *ibdev, const uint8_t *hw_addr)
Find EoIB device.
Definition: eoib.c:677
A Xsigo virtual Ethernet device.
Definition: xsigo.c:113
uint32_t mtu
Maximum MTU.
Definition: ena.h:28
Update gateway information.
Definition: xsigo.h:347
#define bswap_64(value)
Definition: byteswap.h:82
An Infiniband Address Vector.
Definition: infiniband.h:72
static int xve_update_state(struct xsigo_nic *xve, struct eoib_device *eoib, int open)
Update virtual Ethernet device administrative state.
Definition: xsigo.c:385
A Xsigo device.
Definition: xsigo.c:52
static int xsmp_tx_xve_nack(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Send virtual Ethernet error response.
Definition: xsigo.c:773
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void * memset(void *dest, int character, size_t len) __nonnull
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References bswap_64, DBGC, ENOENT, eoib_find(), eoib_force_group_creation(), EPIPE, ib_address_vector::gid, ib_address_vector::gid_present, ib_gid::guid, IB_GUID_ARGS, IB_GUID_FMT, xsigo_device::ibdev, xsigo_nic::mac, memset(), msg(), mtu, xsigo_manager::name, xsigo_nic::name, ntohl, ntohs, NULL, ib_gid::prefix, ib_address_vector::qkey, ib_address_vector::qpn, ib_guid::qword, rc, ib_gid::s, xsigo_manager::xdev, xsmp_tx_xve_nack(), xsmp_tx_xve_params(), XSMP_XVE_UPDATE_GW_CHANGE, XSMP_XVE_UPDATE_GW_DOWN, XSMP_XVE_UPDATE_MTU, XSMP_XVE_UPDATE_STATE, xve_find(), xve_update_mtu(), xve_update_state(), and xve_update_tca().

Referenced by xsmp_rx_xve_install(), xsmp_rx_xve_oper_req(), xsmp_rx_xve_ready(), and xsmp_rx_xve_update().

◆ xsmp_rx_xve_install()

static int xsmp_rx_xve_install ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
static

Handle received virtual Ethernet installation message.

Parameters
xcmConfiguration manager
msgVirtual Ethernet message
Return values
rcReturn status code

Definition at line 931 of file xsigo.c.

932  {
933  union {
934  struct xsmp_xve_mac msg;
936  } mac;
937  char name[ sizeof ( msg->name ) + 1 /* NUL */ ];
938  unsigned long network;
939  unsigned long qkey;
940  unsigned int update;
941  int rc;
942 
943  /* Demangle MAC address (which is erroneously transmitted as
944  * little-endian).
945  */
946  mac.msg.high = bswap_16 ( msg->mac_le.high );
947  mac.msg.low = bswap_32 ( msg->mac_le.low );
948 
949  /* Extract interface name (which may not be NUL-terminated) */
950  memcpy ( name, msg->name, ( sizeof ( name ) - 1 /* NUL */ ) );
951  name[ sizeof ( name ) - 1 /* NUL */ ] = '\0';
952 
953  /* Extract remaining message parameters */
954  network = ntohl ( msg->network );
955  qkey = ntohs ( msg->tca.qkey );
956  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " install \"%s\" %s net %ld qkey "
957  "%#lx\n", xcm->name, IB_GUID_ARGS ( &msg->resource ), name,
958  eth_ntoa ( mac.raw ), network, qkey );
959 
960  /* Create virtual Ethernet device, if applicable */
961  if ( ( xve_find ( xcm, &msg->resource ) == NULL ) &&
962  ( ( rc = xve_create ( xcm, &msg->resource, mac.raw, network,
963  qkey, name ) ) != 0 ) )
964  goto err_create;
965 
966  /* Handle remaining parameters as for a modification message */
967  update = XSMP_XVE_UPDATE_MTU;
968  if ( msg->uplink == XSMP_XVE_UPLINK )
969  update |= XSMP_XVE_UPDATE_GW_CHANGE;
970  return xsmp_rx_xve_modify ( xcm, msg, update );
971 
972  err_create:
973  /* Send NACK */
974  xsmp_tx_xve_nack ( xcm, msg );
975  return rc;
976 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
const char * name
Definition: ath9k_hw.c:1984
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
#define ntohl(value)
Definition: byteswap.h:134
#define ntohs(value)
Definition: byteswap.h:136
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
static int xsmp_rx_xve_modify(struct xsigo_manager *xcm, struct xsmp_xve_message *msg, unsigned int update)
Handle received virtual Ethernet modification message.
Definition: xsigo.c:833
static int xve_create(struct xsigo_manager *xcm, union ib_guid *resource, const uint8_t *mac, unsigned long network, unsigned long qkey, const char *name)
Create virtual Ethernet device.
Definition: xsigo.c:198
char name[16]
Device name.
Definition: xsigo.c:83
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
#define bswap_16(value)
Definition: byteswap.h:58
#define bswap_32(value)
Definition: byteswap.h:70
const char * eth_ntoa(const void *ll_addr)
Transcribe Ethernet address.
Definition: ethernet.c:175
Has uplink.
Definition: xsigo.h:363
unsigned char uint8_t
Definition: stdint.h:10
Update MTU.
Definition: xsigo.h:341
#define ETH_ALEN
Definition: if_ether.h:8
__be32 qkey
Definition: CIB_PRM.h:30
static struct xsigo_nic * xve_find(struct xsigo_manager *xcm, union ib_guid *resource)
Find virtual Ethernet device.
Definition: xsigo.c:263
#define DBGC2(...)
Definition: compiler.h:522
Update gateway information.
Definition: xsigo.h:347
__be32 raw[7]
Definition: CIB_PRM.h:28
XSMP virtual Ethernet MAC address.
Definition: xsigo.h:237
static int xsmp_tx_xve_nack(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Send virtual Ethernet error response.
Definition: xsigo.c:773
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References bswap_16, bswap_32, DBGC2, ETH_ALEN, eth_ntoa(), IB_GUID_ARGS, IB_GUID_FMT, mac, memcpy(), msg(), xsigo_manager::name, name, ntohl, ntohs, NULL, qkey, raw, rc, xsmp_rx_xve_modify(), xsmp_tx_xve_nack(), XSMP_XVE_UPDATE_GW_CHANGE, XSMP_XVE_UPDATE_MTU, XSMP_XVE_UPLINK, xve_create(), and xve_find().

Referenced by xsmp_rx_xve().

◆ xsmp_rx_xve_delete()

static int xsmp_rx_xve_delete ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
static

Handle received virtual Ethernet deletion message.

Parameters
xcmConfiguration manager
msgVirtual Ethernet message
Return values
rcReturn status code

Definition at line 985 of file xsigo.c.

986  {
987  struct xsigo_nic *xve;
988 
989  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " delete\n",
990  xcm->name, IB_GUID_ARGS ( &msg->resource ) );
991 
992  /* Destroy virtual Ethernet device (if any) */
993  if ( ( xve = xve_find ( xcm, &msg->resource ) ) )
994  xve_destroy ( xve );
995 
996  /* Send ACK */
997  msg->code = 0;
998  xsmp_tx_xve ( xcm, msg );
999 
1000  return 0;
1001 }
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
static int xsmp_tx_xve(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Send virtual Ethernet message.
Definition: xsigo.c:687
char name[16]
Device name.
Definition: xsigo.c:83
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
static struct xsigo_nic * xve_find(struct xsigo_manager *xcm, union ib_guid *resource)
Find virtual Ethernet device.
Definition: xsigo.c:263
A Xsigo virtual Ethernet device.
Definition: xsigo.c:113
#define DBGC2(...)
Definition: compiler.h:522
static void xve_destroy(struct xsigo_nic *xve)
Destroy virtual Ethernet device.
Definition: xsigo.c:280
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC2, IB_GUID_ARGS, IB_GUID_FMT, msg(), xsigo_manager::name, xsigo_nic::xcm, xsmp_tx_xve(), xve_destroy(), and xve_find().

Referenced by xsmp_rx_xve().

◆ xsmp_rx_xve_update()

static int xsmp_rx_xve_update ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
static

Handle received virtual Ethernet update message.

Parameters
xcmConfiguration manager
msgVirtual Ethernet message
Return values
rcReturn status code

Definition at line 1010 of file xsigo.c.

1011  {
1012  unsigned int update = ntohl ( msg->update );
1013 
1014  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " update (%08x)\n",
1015  xcm->name, IB_GUID_ARGS ( &msg->resource ), update );
1016 
1017  /* Handle as a modification message */
1018  return xsmp_rx_xve_modify ( xcm, msg, update );
1019 }
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
#define ntohl(value)
Definition: byteswap.h:134
static int xsmp_rx_xve_modify(struct xsigo_manager *xcm, struct xsmp_xve_message *msg, unsigned int update)
Handle received virtual Ethernet modification message.
Definition: xsigo.c:833
char name[16]
Device name.
Definition: xsigo.c:83
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
#define DBGC2(...)
Definition: compiler.h:522
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC2, IB_GUID_ARGS, IB_GUID_FMT, msg(), xsigo_manager::name, ntohl, xsigo_nic::xcm, and xsmp_rx_xve_modify().

Referenced by xsmp_rx_xve().

◆ xsmp_rx_xve_oper_req()

static int xsmp_rx_xve_oper_req ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
static

Handle received virtual Ethernet operational request message.

Parameters
xcmConfiguration manager
msgVirtual Ethernet message
Return values
rcReturn status code

Definition at line 1028 of file xsigo.c.

1029  {
1030 
1031  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " operational request\n",
1032  xcm->name, IB_GUID_ARGS ( &msg->resource ) );
1033 
1034  /* Handle as a nullipotent modification message */
1035  return xsmp_rx_xve_modify ( xcm, msg, 0 );
1036 }
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
static int xsmp_rx_xve_modify(struct xsigo_manager *xcm, struct xsmp_xve_message *msg, unsigned int update)
Handle received virtual Ethernet modification message.
Definition: xsigo.c:833
char name[16]
Device name.
Definition: xsigo.c:83
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
#define DBGC2(...)
Definition: compiler.h:522
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC2, IB_GUID_ARGS, IB_GUID_FMT, msg(), xsigo_manager::name, xsigo_nic::xcm, and xsmp_rx_xve_modify().

Referenced by xsmp_rx_xve().

◆ xsmp_rx_xve_ready()

static int xsmp_rx_xve_ready ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
static

Handle received virtual Ethernet readiness message.

Parameters
xcmConfiguration manager
msgVirtual Ethernet message
Return values
rcReturn status code

Definition at line 1045 of file xsigo.c.

1046  {
1047  int rc;
1048 
1049  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " ready\n",
1050  xcm->name, IB_GUID_ARGS ( &msg->resource ) );
1051 
1052  /* Handle as a nullipotent modification message */
1053  if ( ( rc = xsmp_rx_xve_modify ( xcm, msg, 0 ) ) != 0 )
1054  return rc;
1055 
1056  /* Send an unsolicited operational state update, since there
1057  * is no other way to convey the current operational state.
1058  */
1059  msg->type = XSMP_XVE_TYPE_OPER_REQ;
1060  if ( ( rc = xsmp_rx_xve_modify ( xcm, msg, 0 ) ) != 0 )
1061  return rc;
1062 
1063  return 0;
1064 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
static int xsmp_rx_xve_modify(struct xsigo_manager *xcm, struct xsmp_xve_message *msg, unsigned int update)
Handle received virtual Ethernet modification message.
Definition: xsigo.c:833
char name[16]
Device name.
Definition: xsigo.c:83
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
Get operational state.
Definition: xsigo.h:327
#define DBGC2(...)
Definition: compiler.h:522
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC2, IB_GUID_ARGS, IB_GUID_FMT, msg(), xsigo_manager::name, rc, xsigo_nic::xcm, xsmp_rx_xve_modify(), and XSMP_XVE_TYPE_OPER_REQ.

Referenced by xsmp_rx_xve().

◆ xsmp_rx_xve()

static int xsmp_rx_xve ( struct xsigo_manager xcm,
struct xsmp_xve_message msg 
)
static

Handle received virtual Ethernet message.

Parameters
xcmConfiguration manager
msgVirtual Ethernet message
Return values
rcReturn status code

Definition at line 1073 of file xsigo.c.

1074  {
1075 
1076  DBGCP ( xcm, "XCM %s RX[%d] xve %s\n", xcm->name,
1077  ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ) );
1078  DBGCP_HDA ( xcm, 0, msg, sizeof ( *msg ) );
1079 
1080  /* Handle message according to type */
1081  switch ( msg->type ) {
1082  case XSMP_XVE_TYPE_INSTALL:
1083  return xsmp_rx_xve_install ( xcm, msg );
1084  case XSMP_XVE_TYPE_DELETE:
1085  return xsmp_rx_xve_delete ( xcm, msg );
1086  case XSMP_XVE_TYPE_UPDATE:
1087  return xsmp_rx_xve_update ( xcm, msg );
1089  return xsmp_rx_xve_oper_req ( xcm, msg );
1090  case XSMP_XVE_TYPE_READY:
1091  return xsmp_rx_xve_ready ( xcm, msg );
1092  default:
1093  DBGC ( xcm, "XCM %s RX[%d] xve unexpected %s:\n", xcm->name,
1094  ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ) );
1095  DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );
1096  return -EPROTO;
1097  }
1098 }
#define DBGC(...)
Definition: compiler.h:505
static int xsmp_rx_xve_install(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Handle received virtual Ethernet installation message.
Definition: xsigo.c:931
#define ntohl(value)
Definition: byteswap.h:134
xsmp_xve_type
XSMP virtual Ethernet message types.
Definition: xsigo.h:315
static int xsmp_rx_xve_delete(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Handle received virtual Ethernet deletion message.
Definition: xsigo.c:985
Install virtual NIC.
Definition: xsigo.h:317
char name[16]
Device name.
Definition: xsigo.c:83
#define DBGCP_HDA(...)
Definition: compiler.h:540
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPROTO
Protocol error.
Definition: errno.h:624
Get operational state.
Definition: xsigo.h:327
Update virtual NIC.
Definition: xsigo.h:321
static int xsmp_rx_xve_update(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Handle received virtual Ethernet update message.
Definition: xsigo.c:1010
static int xsmp_rx_xve_oper_req(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Handle received virtual Ethernet operational request message.
Definition: xsigo.c:1028
#define DBGCP(...)
Definition: compiler.h:539
static int xsmp_rx_xve_ready(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Handle received virtual Ethernet readiness message.
Definition: xsigo.c:1045
Delete virtual NIC.
Definition: xsigo.h:319
Virtual NIC is ready.
Definition: xsigo.h:329
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References DBGC, DBGC_HDA, DBGCP, DBGCP_HDA, EPROTO, msg(), xsigo_manager::name, ntohl, xsigo_nic::xcm, xsmp_rx_xve_delete(), xsmp_rx_xve_install(), xsmp_rx_xve_oper_req(), xsmp_rx_xve_ready(), xsmp_rx_xve_update(), XSMP_XVE_TYPE_DELETE, XSMP_XVE_TYPE_INSTALL, XSMP_XVE_TYPE_OPER_REQ, XSMP_XVE_TYPE_READY, and XSMP_XVE_TYPE_UPDATE.

Referenced by xcm_deliver().

◆ xcm_close()

static void xcm_close ( struct xsigo_manager xcm,
int  rc 
)
static

Close configuration manager connection.

Parameters
xcmConfiguration manager
rcReason for close

Definition at line 1113 of file xsigo.c.

1113  {
1114 
1115  DBGC ( xcm, "XCM %s closed: %s\n", xcm->name, strerror ( rc ) );
1116 
1117  /* Stop transmission process */
1118  process_del ( &xcm->process );
1119 
1120  /* Stop keepalive timer */
1121  stop_timer ( &xcm->keepalive );
1122 
1123  /* Restart data transfer interface */
1124  intf_restart ( &xcm->xfer, rc );
1125 
1126  /* Schedule reconnection attempt */
1127  start_timer ( &xcm->reopen );
1128 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
Definition: interface.c:343
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
#define DBGC(...)
Definition: compiler.h:505
void process_del(struct process *process)
Remove process from process list.
Definition: process.c:79
struct process process
Transmission process.
Definition: xsigo.c:94
char name[16]
Device name.
Definition: xsigo.c:83
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
void start_timer(struct retry_timer *timer)
Start timer.
Definition: retry.c:93
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
struct retry_timer reopen
Connection timer.
Definition: xsigo.c:90
struct retry_timer keepalive
Keepalive timer.
Definition: xsigo.c:92

References DBGC, intf_restart(), xsigo_manager::keepalive, xsigo_manager::name, xsigo_manager::process, process_del(), rc, xsigo_manager::reopen, start_timer(), stop_timer(), strerror(), xsigo_nic::xcm, and xsigo_manager::xfer.

Referenced by xcm_deliver(), xcm_keepalive(), and xcm_step().

◆ xcm_step()

static void xcm_step ( struct xsigo_manager xcm)
static

Send data to configuration manager.

Parameters
xcmConfiguration manager

Definition at line 1135 of file xsigo.c.

1135  {
1136  int rc;
1137 
1138  /* Do nothing unless we have something to send */
1139  if ( ! xcm->pending )
1140  return;
1141 
1142  /* Send (empty) connection request, if applicable */
1143  if ( xcm->pending & XCM_TX_CONNECT ) {
1144  if ( ( rc = xfer_deliver_raw ( &xcm->xfer, NULL, 0 ) ) != 0 ) {
1145  DBGC ( xcm, "XCM %s could not send connection request: "
1146  "%s\n", xcm->name, strerror ( rc ) );
1147  goto err;
1148  }
1149  xcm->pending &= ~XCM_TX_CONNECT;
1150  return;
1151  }
1152 
1153  /* Wait until data transfer interface is connected */
1154  if ( ! xfer_window ( &xcm->xfer ) )
1155  return;
1156 
1157  /* Send registration message, if applicable */
1158  if ( xcm->pending & XCM_TX_REGISTER ) {
1159  if ( ( rc = xsmp_tx_session_register ( xcm ) ) != 0 )
1160  goto err;
1162  return;
1163  }
1164 
1165  return;
1166 
1167  err:
1168  xcm_close ( xcm, rc );
1169 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int xsmp_tx_session_register(struct xsigo_manager *xcm)
Send registration message.
Definition: xsigo.c:531
Send connection request.
Definition: xsigo.c:107
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
#define DBGC(...)
Definition: compiler.h:505
Send registration message.
Definition: xsigo.c:109
size_t xfer_window(struct interface *intf)
Check flow control window.
Definition: xfer.c:116
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:288
char name[16]
Device name.
Definition: xsigo.c:83
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static void xcm_close(struct xsigo_manager *xcm, int rc)
Close configuration manager connection.
Definition: xsigo.c:1113
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
unsigned int pending
Pending transmissions.
Definition: xsigo.c:96

References DBGC, xsigo_manager::name, NULL, xsigo_manager::pending, rc, strerror(), xsigo_nic::xcm, xcm_close(), XCM_TX_CONNECT, XCM_TX_REGISTER, xsigo_manager::xfer, xfer_deliver_raw(), xfer_window(), and xsmp_tx_session_register().

◆ xcm_deliver()

static int xcm_deliver ( struct xsigo_manager xcm,
struct io_buffer iobuf,
struct xfer_metadata *meta  __unused 
)
static

Receive data from configuration manager.

Parameters
xcmConfiguration manager
iobufI/O buffer
metaData transfer metadata
Return values
rcReturn status code

Definition at line 1179 of file xsigo.c.

1180  {
1181  union xsmp_message *msg;
1182  size_t len = iob_len ( iobuf );
1183  int rc;
1184 
1185  /* Sanity check */
1186  if ( len < sizeof ( msg->hdr ) ) {
1187  DBGC ( xcm, "XCM %s underlength message:\n", xcm->name );
1188  DBGC_HDA ( xcm, 0, iobuf->data, iob_len ( iobuf ) );
1189  rc = -EPROTO;
1190  goto out;
1191  }
1192  msg = iobuf->data;
1193 
1194  /* Handle message according to type */
1195  if ( ! msg->hdr.type ) {
1196 
1197  /* Ignore unused communication manager private data blocks */
1198  rc = 0;
1199 
1200  } else if ( ( msg->hdr.type == XSMP_TYPE_SESSION ) &&
1201  ( len >= sizeof ( msg->sess ) ) ) {
1202 
1203  /* Session message */
1204  rc = xsmp_rx_session ( xcm, &msg->sess );
1205 
1206  } else if ( ( msg->hdr.type == XSMP_TYPE_XVE ) &&
1207  ( len >= sizeof ( msg->xve ) ) ) {
1208 
1209  /* Virtual Ethernet message */
1210  xsmp_rx_xve ( xcm, &msg->xve );
1211 
1212  /* Virtual Ethernet message errors are non-fatal */
1213  rc = 0;
1214 
1215  } else {
1216 
1217  /* Unknown message */
1218  DBGC ( xcm, "XCM %s unexpected message type %d:\n",
1219  xcm->name, msg->hdr.type );
1220  DBGC_HDA ( xcm, 0, iobuf->data, iob_len ( iobuf ) );
1221  rc = -EPROTO;
1222  }
1223 
1224  out:
1225  free_iob ( iobuf );
1226  if ( rc != 0 )
1227  xcm_close ( xcm, rc );
1228  return rc;
1229 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static int xsmp_rx_session(struct xsigo_manager *xcm, struct xsmp_session_message *msg)
Handle received session message.
Definition: xsigo.c:625
void free_iob(struct io_buffer *iobuf)
Free I/O buffer.
Definition: iobuf.c:146
An XSMP message.
Definition: xsigo.h:367
#define DBGC(...)
Definition: compiler.h:505
Virtual Ethernet message type.
Definition: xsigo.h:161
Session message type.
Definition: xsigo.h:159
__be32 out[4]
Definition: CIB_PRM.h:36
char name[16]
Device name.
Definition: xsigo.c:83
#define DBGC_HDA(...)
Definition: compiler.h:506
#define EPROTO
Protocol error.
Definition: errno.h:624
static size_t iob_len(struct io_buffer *iobuf)
Calculate length of data in an I/O buffer.
Definition: iobuf.h:155
static void xcm_close(struct xsigo_manager *xcm, int rc)
Close configuration manager connection.
Definition: xsigo.c:1113
static int xsmp_rx_xve(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Handle received virtual Ethernet message.
Definition: xsigo.c:1073
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:48
static void msg(unsigned int row, const char *fmt,...)
Print message centred on specified row.
Definition: settings_ui.c:285

References io_buffer::data, DBGC, DBGC_HDA, EPROTO, free_iob(), iob_len(), len, msg(), xsigo_manager::name, out, rc, xcm_close(), xsmp_rx_session(), xsmp_rx_xve(), XSMP_TYPE_SESSION, and XSMP_TYPE_XVE.

◆ xcm_reopen()

static void xcm_reopen ( struct retry_timer timer,
int fail  __unused 
)
static

Handle configuration manager connection timer expiry.

Parameters
timerConnection timer
failFailure indicator

Definition at line 1252 of file xsigo.c.

1252  {
1253  struct xsigo_manager *xcm =
1254  container_of ( timer, struct xsigo_manager, reopen );
1255  struct xsigo_device *xdev = xcm->xdev;
1256  struct ib_device *ibdev = xdev->ibdev;
1257  union ib_gid gid;
1258  int rc;
1259 
1260  /* Stop transmission process */
1261  process_del ( &xcm->process );
1262 
1263  /* Stop keepalive timer */
1264  stop_timer ( &xcm->keepalive );
1265 
1266  /* Restart data transfer interface */
1267  intf_restart ( &xcm->xfer, -ECANCELED );
1268 
1269  /* Reset sequence number */
1270  xcm->seq = 0;
1271 
1272  /* Construct GID */
1273  memcpy ( &gid.s.prefix, &ibdev->gid.s.prefix, sizeof ( gid.s.prefix ) );
1274  memcpy ( &gid.s.guid, &xcm->id.guid, sizeof ( gid.s.guid ) );
1275  DBGC ( xcm, "XCM %s connecting to " IB_GID_FMT "\n",
1276  xcm->name, IB_GID_ARGS ( &gid ) );
1277 
1278  /* Open CMRC connection */
1279  if ( ( rc = ib_cmrc_open ( &xcm->xfer, ibdev, &gid,
1280  &xcm_service_id, xcm->name ) ) != 0 ) {
1281  DBGC ( xcm, "XCM %s could not open CMRC connection: %s\n",
1282  xcm->name, strerror ( rc ) );
1283  start_timer ( &xcm->reopen );
1284  return;
1285  }
1286 
1287  /* Schedule transmissions */
1288  xcm->pending |= ( XCM_TX_CONNECT | XCM_TX_REGISTER );
1289  process_add ( &xcm->process );
1290 
1291  /* Start keepalive timer */
1293 
1294  return;
1295 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
void intf_restart(struct interface *intf, int rc)
Shut down and restart an object interface.
Definition: interface.c:343
int ib_cmrc_open(struct interface *xfer, struct ib_device *ibdev, union ib_gid *dgid, union ib_guid *service_id, const char *name)
Open CMRC connection.
Definition: ib_cmrc.c:397
Send connection request.
Definition: xsigo.c:107
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
#define DBGC(...)
Definition: compiler.h:505
Send registration message.
Definition: xsigo.c:109
void process_del(struct process *process)
Remove process from process list.
Definition: process.c:79
An Infiniband Global Identifier.
Definition: ib_packet.h:33
struct process process
Transmission process.
Definition: xsigo.c:94
#define ECANCELED
Operation canceled.
Definition: errno.h:343
A timer.
Definition: timer.h:28
char name[16]
Device name.
Definition: xsigo.c:83
An Infiniband device.
Definition: infiniband.h:398
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
void * memcpy(void *dest, const void *src, size_t len) __nonnull
struct xsigo_manager_id id
Manager ID.
Definition: xsigo.c:85
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
A Xsigo configuration manager.
Definition: xsigo.c:75
struct ib_gid::@559 s
union ib_guid guid
Port GUID.
Definition: xsigo.h:56
void process_add(struct process *process)
Add process to process list.
Definition: process.c:59
#define IB_GID_ARGS(gid)
Infiniband Global Identifier debug message arguments.
Definition: ib_packet.h:48
union ib_guid prefix
Definition: ib_packet.h:39
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint32_t seq
Transmit sequence number.
Definition: xsigo.c:98
void start_timer(struct retry_timer *timer)
Start timer.
Definition: retry.c:93
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
#define IB_GID_FMT
Infiniband Global Identifier debug message format.
Definition: ib_packet.h:45
struct retry_timer reopen
Connection timer.
Definition: xsigo.c:90
struct retry_timer keepalive
Keepalive timer.
Definition: xsigo.c:92
A Xsigo device.
Definition: xsigo.c:52
static union ib_guid xcm_service_id
Configuration manager service ID.
Definition: xsigo.c:130
u8 gid[16]
Definition: CIB_PRM.h:31
unsigned int pending
Pending transmissions.
Definition: xsigo.c:96
#define XSIGO_KEEPALIVE_INTERVAL
Delay between keepalive requests.
Definition: xsigo.h:398

References container_of, DBGC, ECANCELED, gid, ib_device::gid, xsigo_manager_id::guid, ib_cmrc_open(), IB_GID_ARGS, IB_GID_FMT, xsigo_device::ibdev, xsigo_manager::id, intf_restart(), xsigo_manager::keepalive, memcpy(), xsigo_manager::name, xsigo_manager::pending, ib_gid::prefix, xsigo_manager::process, process_add(), process_del(), rc, xsigo_manager::reopen, ib_gid::s, xsigo_manager::seq, start_timer(), start_timer_fixed(), stop_timer(), strerror(), xcm_service_id, XCM_TX_CONNECT, XCM_TX_REGISTER, xsigo_manager::xdev, xsigo_manager::xfer, and XSIGO_KEEPALIVE_INTERVAL.

Referenced by xcm_create().

◆ xcm_keepalive()

static void xcm_keepalive ( struct retry_timer timer,
int fail  __unused 
)
static

Handle configuration manager keepalive timer expiry.

Parameters
timerConnection timer
failFailure indicator

Definition at line 1303 of file xsigo.c.

1303  {
1304  struct xsigo_manager *xcm =
1306  int rc;
1307 
1308  /* Send keepalive message. The server won't actually respond
1309  * to these, but it gives the RC queue pair a chance to
1310  * complain if it doesn't ever at least get an ACK.
1311  */
1312  if ( ( rc = xsmp_tx_session_hello ( xcm ) ) != 0 ) {
1313  xcm_close ( xcm, rc );
1314  return;
1315  }
1316 
1317  /* Restart keepalive timer */
1319 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
A timer.
Definition: timer.h:28
static int xsmp_tx_session_hello(struct xsigo_manager *xcm)
Send keepalive message.
Definition: xsigo.c:546
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
A Xsigo configuration manager.
Definition: xsigo.c:75
static void xcm_close(struct xsigo_manager *xcm, int rc)
Close configuration manager connection.
Definition: xsigo.c:1113
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
struct retry_timer keepalive
Keepalive timer.
Definition: xsigo.c:92
#define XSIGO_KEEPALIVE_INTERVAL
Delay between keepalive requests.
Definition: xsigo.h:398

References container_of, xsigo_manager::keepalive, rc, start_timer_fixed(), xcm_close(), XSIGO_KEEPALIVE_INTERVAL, and xsmp_tx_session_hello().

Referenced by xcm_create().

◆ xcm_create()

static int xcm_create ( struct xsigo_device xdev,
struct xsigo_manager_id id 
)
static

Create configuration manager.

Parameters
xsigoXsigo device
idConfiguration manager ID
Return values
rcReturn status code

Definition at line 1328 of file xsigo.c.

1329  {
1330  struct xsigo_manager *xcm;
1331 
1332  /* Allocate and initialise structure */
1333  xcm = zalloc ( sizeof ( *xcm ) );
1334  if ( ! xcm )
1335  return -ENOMEM;
1336  ref_init ( &xcm->refcnt, xcm_free );
1337  xcm->xdev = xdev;
1338  ref_get ( &xcm->xdev->refcnt );
1339  snprintf ( xcm->name, sizeof ( xcm->name ), "%s:xcm-%d",
1340  xdev->name, ntohs ( id->lid ) );
1341  memcpy ( &xcm->id, id, sizeof ( xcm->id ) );
1342  intf_init ( &xcm->xfer, &xcm_xfer_desc, &xcm->refcnt );
1343  timer_init ( &xcm->keepalive, xcm_keepalive, &xcm->refcnt );
1344  timer_init ( &xcm->reopen, xcm_reopen, &xcm->refcnt );
1346  INIT_LIST_HEAD ( &xcm->nics );
1347 
1348  /* Start timer to open connection */
1349  start_timer_nodelay ( &xcm->reopen );
1350 
1351  /* Add to list of managers and transfer reference to list */
1352  list_add ( &xcm->list, &xdev->managers );
1353  DBGC ( xcm, "XCM %s created for " IB_GUID_FMT " (LID %d)\n", xcm->name,
1354  IB_GUID_ARGS ( &xcm->id.guid ), ntohs ( id->lid ) );
1355  return 0;
1356 }
struct refcnt refcnt
Reference count.
Definition: xsigo.c:77
struct refcnt refcnt
Reference count.
Definition: xsigo.c:54
static void xcm_keepalive(struct retry_timer *timer, int fail __unused)
Handle configuration manager keepalive timer expiry.
Definition: xsigo.c:1303
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
#define list_add(new, head)
Add a new entry to the head of a list.
Definition: list.h:69
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
#define DBGC(...)
Definition: compiler.h:505
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
#define ntohs(value)
Definition: byteswap.h:136
struct process process
Transmission process.
Definition: xsigo.c:94
char name[16]
Device name.
Definition: xsigo.c:83
struct list_head nics
List of virtual Ethernet devices.
Definition: xsigo.c:101
#define ENOMEM
Not enough space.
Definition: errno.h:534
struct xsigo_device * xdev
Xsigo device.
Definition: xsigo.c:79
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
struct xsigo_manager_id id
Manager ID.
Definition: xsigo.c:85
struct list_head managers
List of configuration managers.
Definition: xsigo.c:71
struct list_head list
List of managers.
Definition: xsigo.c:81
static void xcm_reopen(struct retry_timer *timer, int fail __unused)
Handle configuration manager connection timer expiry.
Definition: xsigo.c:1252
static struct interface_descriptor xcm_xfer_desc
Configuration manager data transfer interface descriptor.
Definition: xsigo.c:1239
A Xsigo configuration manager.
Definition: xsigo.c:75
union ib_guid guid
Port GUID.
Definition: xsigo.h:56
uint8_t id
Request identifier.
Definition: ena.h:12
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
#define ref_get(refcnt)
Get additional reference to object.
Definition: refcnt.h:92
static void xcm_free(struct refcnt *refcnt)
Free configuration manager.
Definition: xsigo.c:164
static void process_init_stopped(struct process *process, struct process_descriptor *desc, struct refcnt *refcnt)
Initialise process without adding to process list.
Definition: process.h:145
const char * name
Device name.
Definition: xsigo.c:60
static struct process_descriptor xcm_process_desc
Configuration manager process descriptor.
Definition: xsigo.c:1243
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
struct retry_timer reopen
Connection timer.
Definition: xsigo.c:90
struct retry_timer keepalive
Keepalive timer.
Definition: xsigo.c:92
static void intf_init(struct interface *intf, struct interface_descriptor *desc, struct refcnt *refcnt)
Initialise an object interface.
Definition: interface.h:203

References DBGC, ENOMEM, xsigo_manager_id::guid, IB_GUID_ARGS, IB_GUID_FMT, id, xsigo_manager::id, INIT_LIST_HEAD, intf_init(), xsigo_manager::keepalive, xsigo_manager::list, list_add, xsigo_device::managers, memcpy(), xsigo_device::name, xsigo_manager::name, xsigo_manager::nics, ntohs, xsigo_manager::process, process_init_stopped(), ref_get, ref_init, xsigo_manager::refcnt, xsigo_device::refcnt, xsigo_manager::reopen, snprintf(), start_timer_nodelay(), xcm_free(), xcm_keepalive(), xcm_process_desc, xcm_reopen(), xcm_xfer_desc, xsigo_manager::xdev, xsigo_manager::xfer, and zalloc().

Referenced by xcm_list().

◆ xcm_find()

static struct xsigo_manager* xcm_find ( struct xsigo_device xdev,
struct xsigo_manager_id id 
)
static

Find configuration manager.

Parameters
xsigoXsigo device
idConfiguration manager ID
Return values
xcmConfiguration manager, or NULL

Definition at line 1365 of file xsigo.c.

1366  {
1367  struct xsigo_manager *xcm;
1368  union ib_guid *guid = &id->guid;
1369 
1370  /* Find configuration manager */
1371  list_for_each_entry ( xcm, &xdev->managers, list ) {
1372  if ( memcmp ( guid, &xcm->id.guid, sizeof ( *guid ) ) == 0 )
1373  return xcm;
1374  }
1375  return NULL;
1376 }
struct xsigo_manager_id id
Manager ID.
Definition: xsigo.c:85
struct list_head managers
List of configuration managers.
Definition: xsigo.c:71
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
A Xsigo configuration manager.
Definition: xsigo.c:75
union ib_guid guid
Port GUID.
Definition: xsigo.h:56
An Infiniband Globally Unique Identifier.
Definition: ib_packet.h:18
uint64_t guid
GUID.
Definition: edd.h:30
int memcmp(const void *first, const void *second, size_t len)
Compare memory regions.
Definition: string.c:114
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321

References guid, xsigo_manager_id::guid, xsigo_manager::id, list_for_each_entry, xsigo_device::managers, memcmp(), and NULL.

Referenced by xcm_list().

◆ xcm_destroy()

static void xcm_destroy ( struct xsigo_manager xcm)
static

Destroy configuration manager.

Parameters
xcmConfiguration manager

Definition at line 1383 of file xsigo.c.

1383  {
1384  struct xsigo_nic *xve;
1385 
1386  /* Remove all EoIB NICs */
1387  while ( ( xve = list_first_entry ( &xcm->nics, struct xsigo_nic,
1388  list ) ) ) {
1389  xve_destroy ( xve );
1390  }
1391 
1392  /* Stop transmission process */
1393  process_del ( &xcm->process );
1394 
1395  /* Stop timers */
1396  stop_timer ( &xcm->keepalive );
1397  stop_timer ( &xcm->reopen );
1398 
1399  /* Shut down data transfer interface */
1400  intf_shutdown ( &xcm->xfer, 0 );
1401 
1402  /* Remove from list of managers and drop list's reference */
1403  DBGC ( xcm, "XCM %s destroyed\n", xcm->name );
1404  list_del ( &xcm->list );
1405  ref_put ( &xcm->refcnt );
1406 }
struct refcnt refcnt
Reference count.
Definition: xsigo.c:77
struct list_head list
List of virtual Ethernet devices.
Definition: xsigo.c:117
void intf_shutdown(struct interface *intf, int rc)
Shut down an object interface.
Definition: interface.c:278
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
#define DBGC(...)
Definition: compiler.h:505
void process_del(struct process *process)
Remove process from process list.
Definition: process.c:79
struct process process
Transmission process.
Definition: xsigo.c:94
char name[16]
Device name.
Definition: xsigo.c:83
#define list_first_entry(list, type, member)
Get the container of the first entry in a list.
Definition: list.h:333
struct list_head nics
List of virtual Ethernet devices.
Definition: xsigo.c:101
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct xsigo_manager * xcm
Configuration manager.
Definition: xsigo.c:115
struct list_head list
List of managers.
Definition: xsigo.c:81
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
A Xsigo virtual Ethernet device.
Definition: xsigo.c:113
struct retry_timer reopen
Connection timer.
Definition: xsigo.c:90
static void xve_destroy(struct xsigo_nic *xve)
Destroy virtual Ethernet device.
Definition: xsigo.c:280
struct retry_timer keepalive
Keepalive timer.
Definition: xsigo.c:92
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106

References DBGC, intf_shutdown(), xsigo_manager::keepalive, xsigo_manager::list, xsigo_nic::list, list_del, list_first_entry, xsigo_manager::name, xsigo_manager::nics, xsigo_manager::process, process_del(), ref_put, xsigo_manager::refcnt, xsigo_manager::reopen, stop_timer(), xsigo_nic::xcm, xsigo_manager::xfer, and xve_destroy().

Referenced by xcm_list().

◆ xcm_list()

static int xcm_list ( struct xsigo_device xdev,
struct xsigo_manager_id ids,
unsigned int  count 
)
static

Synchronise list of configuration managers.

Parameters
xdevXsigo device
idsList of manager IDs
countNumber of manager IDs
Return values
rcReturn status code

Definition at line 1416 of file xsigo.c.

1417  {
1418  struct xsigo_manager_id *id;
1419  struct xsigo_manager *xcm;
1420  struct xsigo_manager *tmp;
1421  struct list_head list;
1422  unsigned int i;
1423  int rc;
1424 
1425  /* Create list of managers to be retained */
1426  INIT_LIST_HEAD ( &list );
1427  for ( i = 0, id = ids ; i < count ; i++, id++ ) {
1428  if ( ( xcm = xcm_find ( xdev, id ) ) ) {
1429  list_del ( &xcm->list );
1430  list_add_tail ( &xcm->list, &list );
1431  }
1432  }
1433 
1434  /* Destroy any managers not in the list */
1435  list_for_each_entry_safe ( xcm, tmp, &xdev->managers, list )
1436  xcm_destroy ( xcm );
1437  list_splice ( &list, &xdev->managers );
1438 
1439  /* Create any new managers in the list, and force reconnection
1440  * for any changed LIDs.
1441  */
1442  for ( i = 0, id = ids ; i < count ; i++, id++ ) {
1443  if ( ( xcm = xcm_find ( xdev, id ) ) ) {
1444  if ( xcm->id.lid != id->lid )
1445  start_timer_nodelay ( &xcm->reopen );
1446  continue;
1447  }
1448  if ( ( rc = xcm_create ( xdev, id ) ) != 0 ) {
1449  DBGC ( xdev, "XDEV %s could not create manager: %s\n",
1450  xdev->name, strerror ( rc ) );
1451  return rc;
1452  }
1453  }
1454 
1455  return 0;
1456 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void xcm_destroy(struct xsigo_manager *xcm)
Destroy configuration manager.
Definition: xsigo.c:1383
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
static unsigned int unsigned int unsigned int size_t uint8_t * ids
Definition: ena.h:676
static int xcm_create(struct xsigo_device *xdev, struct xsigo_manager_id *id)
Create configuration manager.
Definition: xsigo.c:1328
#define DBGC(...)
Definition: compiler.h:505
A doubly-linked list entry (or list head)
Definition: list.h:18
unsigned long tmp
Definition: linux_pci.h:53
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct xsigo_manager_id id
Manager ID.
Definition: xsigo.c:85
struct list_head managers
List of configuration managers.
Definition: xsigo.c:71
struct list_head list
List of managers.
Definition: xsigo.c:81
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
A Xsigo configuration manager.
Definition: xsigo.c:75
uint16_t lid
LID.
Definition: xsigo.h:58
static struct xsigo_manager * xcm_find(struct xsigo_device *xdev, struct xsigo_manager_id *id)
Find configuration manager.
Definition: xsigo.c:1365
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint8_t id
Request identifier.
Definition: ena.h:12
const char * name
Device name.
Definition: xsigo.c:60
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
uint16_t count
Number of entries.
Definition: ena.h:22
#define list_splice(list, entry)
Move all entries from one list into another list.
Definition: list.h:220
A Xsigo configuration manager identifier.
Definition: xsigo.h:54
struct retry_timer reopen
Connection timer.
Definition: xsigo.c:90

References count, DBGC, id, xsigo_manager::id, ids, INIT_LIST_HEAD, xsigo_manager_id::lid, xsigo_manager::list, list_add_tail, list_del, list_for_each_entry_safe, list_splice, xsigo_device::managers, xsigo_device::name, rc, xsigo_manager::reopen, start_timer_nodelay(), strerror(), tmp, xcm_create(), xcm_destroy(), and xcm_find().

Referenced by xsigo_ib_remove(), and xsigo_xcm_complete().

◆ xsigo_xcm_complete()

static void xsigo_xcm_complete ( struct ib_device ibdev,
struct ib_mad_interface *mi  __unused,
struct ib_mad_transaction madx,
int  rc,
union ib_mad mad,
struct ib_address_vector *av  __unused 
)
static

Handle configuration manager lookup completion.

Parameters
ibdevInfiniband device
miManagement interface
madxManagement transaction
rcStatus code
madReceived MAD (or NULL on error)
avSource address vector (or NULL on error)

Definition at line 1483 of file xsigo.c.

1487  {
1488  struct xsigo_device *xdev = ib_madx_get_ownerdata ( madx );
1489  union xsigo_mad *xsmad = container_of ( mad, union xsigo_mad, mad );
1490  struct xsigo_managers_reply *reply = &xsmad->reply;
1491 
1492  /* Check for failures */
1493  if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) )
1494  rc = -ENODEV;
1495  if ( rc != 0 ) {
1496  DBGC ( xdev, "XDEV %s manager lookup failed: %s\n",
1497  xdev->name, strerror ( rc ) );
1498  goto out;
1499  }
1500 
1501  /* Sanity checks */
1502  if ( reply->count > ( sizeof ( reply->manager ) /
1503  sizeof ( reply->manager[0] ) ) ) {
1504  DBGC ( xdev, "XDEV %s has too many managers (%d)\n",
1505  xdev->name, reply->count );
1506  goto out;
1507  }
1508 
1509  /* Synchronise list of managers */
1510  if ( ( rc = xcm_list ( xdev, reply->manager, reply->count ) ) != 0 )
1511  goto out;
1512 
1513  /* Report an empty list of managers */
1514  if ( reply->count == 0 )
1515  DBGC ( xdev, "XDEV %s has no managers\n", xdev->name );
1516 
1517  /* Delay next discovery attempt */
1519 
1520 out:
1521  /* Destroy the completed transaction */
1522  ib_destroy_madx ( ibdev, ibdev->gsi, madx );
1523  xdev->madx = NULL;
1524 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
uint8_t count
Number of XCM records.
Definition: xsigo.h:111
A Xsigo MAD.
Definition: xsigo.h:123
#define DBGC(...)
Definition: compiler.h:505
struct xsigo_manager_id manager[8]
Managers.
Definition: xsigo.h:117
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:461
__be32 out[4]
Definition: CIB_PRM.h:36
#define XSIGO_DISCOVERY_SUCCESS_DELAY
Delay between successful discovery attempts.
Definition: xsigo.h:392
struct ib_mad_transaction * madx
Discovery management transaction (if any)
Definition: xsigo.c:68
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
A Xsigo configuration manager reply MAD.
Definition: xsigo.h:103
struct retry_timer discovery
Discovery timer.
Definition: xsigo.c:66
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
static int xcm_list(struct xsigo_device *xdev, struct xsigo_manager_id *ids, unsigned int count)
Synchronise list of configuration managers.
Definition: xsigo.c:1416
#define ENODEV
No such device.
Definition: errno.h:509
struct xsigo_managers_reply reply
Configuration manager reply.
Definition: xsigo.h:129
const char * name
Device name.
Definition: xsigo.c:60
static __always_inline void * ib_madx_get_ownerdata(struct ib_mad_transaction *madx)
Get Infiniband management transaction owner-private data.
Definition: ib_mi.h:117
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
#define IB_MGMT_STATUS_OK
Definition: ib_mad.h:580
A Xsigo device.
Definition: xsigo.c:52
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12
uint16_t status
Definition: ib_mad.h:543
void ib_destroy_madx(struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx)
Destroy management transaction.
Definition: ib_mi.c:327

References container_of, xsigo_managers_reply::count, DBGC, xsigo_device::discovery, ENODEV, ib_device::gsi, ib_mad::hdr, htons, ib_destroy_madx(), ib_madx_get_ownerdata(), IB_MGMT_STATUS_OK, mad, xsigo_device::madx, xsigo_managers_reply::manager, xsigo_device::name, NULL, out, rc, xsigo_mad::reply, start_timer_fixed(), ib_mad_hdr::status, strerror(), xcm_list(), and XSIGO_DISCOVERY_SUCCESS_DELAY.

◆ xsigo_xds_complete()

static void xsigo_xds_complete ( struct ib_device ibdev,
struct ib_mad_interface *mi  __unused,
struct ib_mad_transaction madx,
int  rc,
union ib_mad mad,
struct ib_address_vector *av  __unused 
)
static

Handle directory service lookup completion.

Parameters
ibdevInfiniband device
miManagement interface
madxManagement transaction
rcStatus code
madReceived MAD (or NULL on error)
avSource address vector (or NULL on error)

Definition at line 1544 of file xsigo.c.

1548  {
1549  struct xsigo_device *xdev = ib_madx_get_ownerdata ( madx );
1550  union xsigo_mad *xsmad = container_of ( mad, union xsigo_mad, mad );
1551  struct xsigo_managers_request *request = &xsmad->request;
1552  struct ib_service_record *svc;
1553  struct ib_address_vector dest;
1554  union ib_guid *guid;
1555 
1556  /* Allow for reuse of transaction pointer */
1557  xdev->madx = NULL;
1558 
1559  /* Check for failures */
1560  if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) )
1561  rc = -ENODEV;
1562  if ( rc != 0 ) {
1563  DBGC ( xdev, "XDEV %s directory lookup failed: %s\n",
1564  xdev->name, strerror ( rc ) );
1565  goto out;
1566  }
1567 
1568  /* Construct address vector */
1569  memset ( &dest, 0, sizeof ( dest ) );
1570  svc = &mad->sa.sa_data.service_record;
1571  dest.lid = ntohs ( svc->data16[0] );
1572  dest.sl = ibdev->sm_sl;
1573  dest.qpn = IB_QPN_GSI;
1574  dest.qkey = IB_QKEY_GSI;
1575  guid = ( ( union ib_guid * ) &svc->data64[0] );
1576  DBGC2 ( xdev, "XDEV %s found directory at LID %d GUID " IB_GUID_FMT
1577  "\n", xdev->name, dest.lid, IB_GUID_ARGS ( guid ) );
1578 
1579  /* Construct request (reusing MAD buffer) */
1580  memset ( request, 0, sizeof ( *request ) );
1581  request->mad_hdr.mgmt_class = XSIGO_MGMT_CLASS;
1582  request->mad_hdr.class_version = XSIGO_MGMT_CLASS_VERSION;
1583  request->mad_hdr.method = IB_MGMT_METHOD_GET;
1584  request->mad_hdr.attr_id = htons ( XSIGO_ATTR_XCM_REQUEST );
1585  memcpy ( &request->server.guid, &ibdev->gid.s.guid,
1586  sizeof ( request->server.guid ) );
1587  snprintf ( request->os_version, sizeof ( request->os_version ),
1588  "%s %s", product_short_name, product_version );
1589  snprintf ( request->arch, sizeof ( request->arch ), _S2 ( ARCH ) );
1590  request->os_type = XSIGO_OS_TYPE_GENERIC;
1591  request->resources = htons ( XSIGO_RESOURCES_PRESENT |
1594 
1595  /* The handling of this request on the server side is a
1596  * textbook example of how not to design a wire protocol. The
1597  * server uses the _driver_ version number to determine which
1598  * fields are present.
1599  */
1600  request->driver_version = htonl ( 0x2a2a2a );
1601 
1602  /* The build version field is ignored unless it happens to
1603  * contain the substring "xg-".
1604  */
1605  snprintf ( request->build, sizeof ( request->build ),
1606  "not-xg-%08lx", build_id );
1607 
1608  /* The server side user interface occasionally has no way to
1609  * refer to an entry with an empty hostname.
1610  */
1611  fetch_string_setting ( NULL, &hostname_setting, request->hostname,
1612  sizeof ( request->hostname ) );
1613  if ( ! request->hostname[0] ) {
1614  snprintf ( request->hostname, sizeof ( request->hostname ),
1616  IB_GUID_ARGS ( &ibdev->gid.s.guid ) );
1617  }
1618 
1619  /* Start configuration manager lookup */
1620  xdev->madx = ib_create_madx ( ibdev, ibdev->gsi, mad, &dest,
1622  if ( ! xdev->madx ) {
1623  DBGC ( xdev, "XDEV %s could not start manager lookup\n",
1624  xdev->name );
1625  goto out;
1626  }
1627  ib_madx_set_ownerdata ( xdev->madx, xdev );
1628 
1629 out:
1630  /* Destroy the completed transaction */
1631  ib_destroy_madx ( ibdev, ibdev->gsi, madx );
1632 }
const char product_short_name[]
Product short name string.
Definition: version.c:76
#define IB_MGMT_METHOD_GET
Definition: ib_mad.h:569
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
Virtual Ethernet resource type.
Definition: xsigo.h:40
union ib_guid guid
Definition: ib_packet.h:40
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
#define _S2(x)
Stringify expanded argument.
Definition: compiler.h:53
static struct xsigo_discovery xsigo_xcm_discovery
Configuration manager lookup discovery stage.
Definition: xsigo.c:1527
A Xsigo MAD.
Definition: xsigo.h:123
struct xsigo_managers_request request
Configuration manager request.
Definition: xsigo.h:127
#define DBGC(...)
Definition: compiler.h:505
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:461
#define ntohs(value)
Definition: byteswap.h:136
#define XSIGO_ATTR_XCM_REQUEST
Xsigo configuration manager request MAD.
Definition: xsigo.h:29
uint64_t data64[2]
Definition: ib_mad.h:237
#define htonl(value)
Definition: byteswap.h:133
#define IB_QKEY_GSI
General service interface queue key.
Definition: infiniband.h:30
__be32 out[4]
Definition: CIB_PRM.h:36
void * memcpy(void *dest, const void *src, size_t len) __nonnull
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
union ib_sa_data sa_data
Definition: ib_mad.h:600
unsigned long build_id
Build ID.
Definition: version.c:61
struct ib_mad_transaction * madx
Discovery management transaction (if any)
Definition: xsigo.c:68
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct ib_mad_transaction * ib_create_madx(struct ib_device *ibdev, struct ib_mad_interface *mi, union ib_mad *mad, struct ib_address_vector *av, struct ib_mad_transaction_operations *op)
Create management transaction.
Definition: ib_mi.c:287
struct ib_gid::@559 s
int fetch_string_setting(struct settings *settings, const struct setting *setting, char *data, size_t len)
Fetch value of string setting.
Definition: settings.c:841
static __always_inline void ib_madx_set_ownerdata(struct ib_mad_transaction *madx, void *priv)
Set Infiniband management transaction owner-private data.
Definition: ib_mi.h:106
uint16_t data16[8]
Definition: ib_mad.h:235
static void * dest
Definition: strings.h:176
uint8_t sm_sl
Subnet manager SL.
Definition: infiniband.h:447
A Xsigo configuration manager request MAD.
Definition: xsigo.h:64
#define IB_QPN_GSI
General service interface QPN.
Definition: infiniband.h:27
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
struct ib_service_record service_record
Definition: ib_mad.h:298
An Infiniband Globally Unique Identifier.
Definition: ib_packet.h:18
#define ENODEV
No such device.
Definition: errno.h:509
const char product_version[]
Product version string.
Definition: version.c:70
#define XSIGO_MGMT_CLASS_VERSION
Xsigo management class version.
Definition: xsigo.h:26
const char * name
Device name.
Definition: xsigo.c:60
Absence-of-high-availability "resource" type.
Definition: xsigo.h:42
struct ib_mad_sa sa
Definition: ib_mad.h:613
static __always_inline void * ib_madx_get_ownerdata(struct ib_mad_transaction *madx)
Get Infiniband management transaction owner-private data.
Definition: ib_mi.h:117
#define XSIGO_MGMT_CLASS
Xsigo management class.
Definition: xsigo.h:23
uint64_t guid
GUID.
Definition: edd.h:30
struct ib_mad_transaction_operations op
Management transaction operations.
Definition: xsigo.c:1470
struct ib_mad_hdr hdr
Definition: ib_mad.h:611
#define DBGC2(...)
Definition: compiler.h:522
#define IB_MGMT_STATUS_OK
Definition: ib_mad.h:580
u8 request[0]
List of IEs requested.
Definition: ieee80211.h:16
#define XSIGO_OS_TYPE_GENERIC
Generic operating system type.
Definition: xsigo.h:32
int snprintf(char *buf, size_t size, const char *fmt,...)
Write a formatted string to a buffer.
Definition: vsprintf.c:382
An Infiniband Address Vector.
Definition: infiniband.h:72
A Xsigo device.
Definition: xsigo.c:52
#define XSIGO_RESOURCES_PRESENT
Resource types are present.
Definition: xsigo.h:100
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define htons(value)
Definition: byteswap.h:135
union ib_mad mad
Definition: arbel.h:12
uint16_t status
Definition: ib_mad.h:543
void ib_destroy_madx(struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx)
Destroy management transaction.
Definition: ib_mi.c:327
void * memset(void *dest, int character, size_t len) __nonnull

References _S2, build_id, container_of, ib_service_record::data16, ib_service_record::data64, DBGC, DBGC2, dest, ENODEV, fetch_string_setting(), ib_device::gid, ib_device::gsi, guid, ib_gid::guid, ib_mad::hdr, htonl, htons, ib_create_madx(), ib_destroy_madx(), IB_GUID_ARGS, IB_GUID_FMT, ib_madx_get_ownerdata(), ib_madx_set_ownerdata(), IB_MGMT_METHOD_GET, IB_MGMT_STATUS_OK, IB_QKEY_GSI, IB_QPN_GSI, mad, xsigo_device::madx, memcpy(), memset(), xsigo_device::name, ntohs, NULL, xsigo_discovery::op, out, product_short_name, product_version, rc, request, xsigo_mad::request, ib_gid::s, ib_mad::sa, ib_mad_sa::sa_data, ib_sa_data::service_record, ib_device::sm_sl, snprintf(), ib_mad_hdr::status, strerror(), XSIGO_ATTR_XCM_REQUEST, XSIGO_MGMT_CLASS, XSIGO_MGMT_CLASS_VERSION, XSIGO_OS_TYPE_GENERIC, XSIGO_RESOURCE_NO_HA, XSIGO_RESOURCE_XVE, XSIGO_RESOURCES_PRESENT, and xsigo_xcm_discovery.

◆ xsigo_discover()

static void xsigo_discover ( struct retry_timer timer,
int over  __unused 
)
static

Discover configuration managers.

Parameters
timerRetry timer
overFailure indicator

Definition at line 1648 of file xsigo.c.

1648  {
1649  struct xsigo_device *xdev =
1651  struct ib_device *ibdev = xdev->ibdev;
1652  struct xsigo_discovery *discovery;
1653 
1654  /* Restart timer */
1656 
1657  /* Cancel any pending discovery transaction */
1658  if ( xdev->madx ) {
1659  discovery = container_of ( xdev->madx->op,
1660  struct xsigo_discovery, op );
1661  DBGC ( xdev, "XDEV %s timed out waiting for %s lookup\n",
1662  xdev->name, discovery->name );
1663  ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
1664  xdev->madx = NULL;
1665  }
1666 
1667  /* Start directory service lookup */
1668  xdev->madx = ib_create_service_madx ( ibdev, ibdev->gsi,
1671  if ( ! xdev->madx ) {
1672  DBGC ( xdev, "XDEV %s could not start directory lookup\n",
1673  xdev->name );
1674  return;
1675  }
1676  ib_madx_set_ownerdata ( xdev->madx, xdev );
1677 }
#define DBGC(...)
Definition: compiler.h:505
static struct xsigo_discovery xsigo_xds_discovery
Directory service lookup discovery stage.
Definition: xsigo.c:1635
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:461
A stage of discovery.
Definition: xsigo.c:1466
A timer.
Definition: timer.h:28
An Infiniband device.
Definition: infiniband.h:398
struct ib_mad_transaction * madx
Discovery management transaction (if any)
Definition: xsigo.c:68
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct retry_timer discovery
Discovery timer.
Definition: xsigo.c:66
static __always_inline void ib_madx_set_ownerdata(struct ib_mad_transaction *madx, void *priv)
Set Infiniband management transaction owner-private data.
Definition: ib_mi.h:106
#define XSIGO_DISCOVERY_FAILURE_DELAY
Delay between unsuccessful discovery attempts.
Definition: xsigo.h:386
#define XDS_SERVICE_NAME
Xsigo directory service record name.
Definition: xsigo.h:17
struct ib_mad_transaction_operations * op
Transaction operations.
Definition: ib_mi.h:82
struct ib_mad_transaction * ib_create_service_madx(struct ib_device *ibdev, struct ib_mad_interface *mi, const char *name, struct ib_mad_transaction_operations *op)
Create service record management transaction.
Definition: ib_service.c:49
const char * name
Device name.
Definition: xsigo.c:60
struct ib_mad_transaction_operations op
Management transaction operations.
Definition: xsigo.c:1470
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
const char * name
Name.
Definition: xsigo.c:1468
A Xsigo device.
Definition: xsigo.c:52
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void ib_destroy_madx(struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx)
Destroy management transaction.
Definition: ib_mi.c:327

References container_of, DBGC, xsigo_device::discovery, ib_device::gsi, ib_create_service_madx(), ib_destroy_madx(), ib_madx_set_ownerdata(), xsigo_device::ibdev, xsigo_device::madx, xsigo_device::name, xsigo_discovery::name, NULL, ib_mad_transaction::op, op, xsigo_discovery::op, start_timer_fixed(), XDS_SERVICE_NAME, XSIGO_DISCOVERY_FAILURE_DELAY, and xsigo_xds_discovery.

Referenced by xsigo_ib_probe().

◆ xsigo_ib_open()

static void xsigo_ib_open ( struct retry_timer opener,
int over  __unused 
)
static

Open link and start discovery.

Parameters
openerLink opener
overFailure indicator

Definition at line 1692 of file xsigo.c.

1692  {
1693  struct xsigo_device *xdev =
1694  container_of ( opener, struct xsigo_device, opener );
1695  struct ib_device *ibdev = xdev->ibdev;
1696  int rc;
1697 
1698  /* Open Infiniband device */
1699  if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
1700  DBGC ( xdev, "XDEV %s could not open: %s\n",
1701  xdev->name, strerror ( rc ) );
1702  /* Delay and try again */
1704  return;
1705  }
1706 
1707  /* If link is already up, then start discovery */
1708  if ( ib_link_ok ( ibdev ) )
1709  start_timer_nodelay ( &xdev->discovery );
1710 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static __always_inline int ib_link_ok(struct ib_device *ibdev)
Check link state of Infiniband device.
Definition: infiniband.h:565
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
struct retry_timer opener
Link opener timer.
Definition: xsigo.c:63
#define DBGC(...)
Definition: compiler.h:505
int ib_open(struct ib_device *ibdev)
Open port.
Definition: infiniband.c:652
#define XSIGO_OPEN_RETRY_DELAY
Delay between attempts to open the Infiniband device.
Definition: xsigo.h:380
An Infiniband device.
Definition: infiniband.h:398
#define container_of(ptr, type, field)
Get containing structure.
Definition: stddef.h:35
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct retry_timer discovery
Discovery timer.
Definition: xsigo.c:66
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
const char * name
Device name.
Definition: xsigo.c:60
void start_timer_fixed(struct retry_timer *timer, unsigned long timeout)
Start timer with a specified timeout.
Definition: retry.c:64
A Xsigo device.
Definition: xsigo.c:52

References container_of, DBGC, xsigo_device::discovery, ib_link_ok(), ib_open(), xsigo_device::ibdev, xsigo_device::name, xsigo_device::opener, rc, start_timer_fixed(), start_timer_nodelay(), strerror(), and XSIGO_OPEN_RETRY_DELAY.

Referenced by xsigo_ib_probe().

◆ xsigo_ib_probe()

static int xsigo_ib_probe ( struct ib_device ibdev)
static

Probe Xsigo device.

Parameters
ibdevInfiniband device
Return values
rcReturn status code

Definition at line 1718 of file xsigo.c.

1718  {
1719  struct xsigo_device *xdev;
1720 
1721  /* Allocate and initialise structure */
1722  xdev = zalloc ( sizeof ( *xdev ) );
1723  if ( ! xdev )
1724  return -ENOMEM;
1725  ref_init ( &xdev->refcnt, xsigo_free );
1726  xdev->ibdev = ibdev_get ( ibdev );
1727  xdev->name = ibdev->name;
1728  timer_init ( &xdev->opener, xsigo_ib_open, &xdev->refcnt );
1729  timer_init ( &xdev->discovery, xsigo_discover, &xdev->refcnt );
1730  INIT_LIST_HEAD ( &xdev->managers );
1731 
1732  /* Start timer to open Infiniband device. (We are currently
1733  * within the Infiniband device probe callback list; opening
1734  * the device here would have interesting side-effects.)
1735  */
1736  start_timer_nodelay ( &xdev->opener );
1737 
1738  /* Add to list of devices and transfer reference to list */
1739  list_add_tail ( &xdev->list, &xsigo_devices );
1740  DBGC ( xdev, "XDEV %s created for " IB_GUID_FMT "\n",
1741  xdev->name, IB_GUID_ARGS ( &ibdev->gid.s.guid ) );
1742  return 0;
1743 }
struct refcnt refcnt
Reference count.
Definition: xsigo.c:54
char name[IBDEV_NAME_LEN]
Name of this Infiniband device.
Definition: infiniband.h:408
union ib_guid guid
Definition: ib_packet.h:40
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
union ib_gid gid
Port GID (comprising GID prefix and port GUID)
Definition: infiniband.h:441
#define ref_init(refcnt, free)
Initialise a reference counter.
Definition: refcnt.h:64
struct retry_timer opener
Link opener timer.
Definition: xsigo.c:63
static void xsigo_ib_open(struct retry_timer *opener, int over __unused)
Open link and start discovery.
Definition: xsigo.c:1692
#define DBGC(...)
Definition: compiler.h:505
#define IB_GUID_ARGS(guid)
Infiniband Globally Unique Identifier debug message arguments.
Definition: ib_packet.h:29
static __always_inline struct ib_device * ibdev_get(struct ib_device *ibdev)
Get reference to Infiniband device.
Definition: infiniband.h:587
#define ENOMEM
Not enough space.
Definition: errno.h:534
#define IB_GUID_FMT
Infiniband Globally Unique Identifier debug message format.
Definition: ib_packet.h:26
struct list_head managers
List of configuration managers.
Definition: xsigo.c:71
struct list_head list
List of Xsigo devices.
Definition: xsigo.c:58
#define list_add_tail(new, head)
Add a new entry to the tail of a list.
Definition: list.h:93
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct ib_gid::@559 s
struct retry_timer discovery
Discovery timer.
Definition: xsigo.c:66
void * zalloc(size_t size)
Allocate cleared memory.
Definition: malloc.c:624
const char * name
Device name.
Definition: xsigo.c:60
#define INIT_LIST_HEAD(list)
Initialise a list head.
Definition: list.h:45
static void xsigo_free(struct refcnt *refcnt)
Free Xsigo device.
Definition: xsigo.c:142
A Xsigo device.
Definition: xsigo.c:52
static void xsigo_discover(struct retry_timer *timer, int over __unused)
Discover configuration managers.
Definition: xsigo.c:1648

References DBGC, xsigo_device::discovery, ENOMEM, ib_device::gid, ib_gid::guid, IB_GUID_ARGS, IB_GUID_FMT, xsigo_device::ibdev, ibdev_get(), INIT_LIST_HEAD, xsigo_device::list, list_add_tail, xsigo_device::managers, xsigo_device::name, ib_device::name, xsigo_device::opener, ref_init, xsigo_device::refcnt, ib_gid::s, start_timer_nodelay(), xsigo_discover(), xsigo_free(), xsigo_ib_open(), and zalloc().

◆ xsigo_ib_notify()

static void xsigo_ib_notify ( struct ib_device ibdev)
static

Handle device or link status change.

Parameters
ibdevInfiniband device

Definition at line 1750 of file xsigo.c.

1750  {
1751  struct xsigo_device *xdev;
1752 
1753  /* Stop/restart discovery on any attached devices */
1754  list_for_each_entry ( xdev, &xsigo_devices, list ) {
1755 
1756  /* Skip non-attached devices */
1757  if ( xdev->ibdev != ibdev )
1758  continue;
1759 
1760  /* Stop any ongoing discovery */
1761  if ( xdev->madx ) {
1762  ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
1763  xdev->madx = NULL;
1764  }
1765  stop_timer ( &xdev->discovery );
1766 
1767  /* If link is up, then start discovery */
1768  if ( ib_link_ok ( ibdev ) )
1769  start_timer_nodelay ( &xdev->discovery );
1770  }
1771 }
static __always_inline int ib_link_ok(struct ib_device *ibdev)
Check link state of Infiniband device.
Definition: infiniband.h:565
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:461
struct ib_mad_transaction * madx
Discovery management transaction (if any)
Definition: xsigo.c:68
struct list_head list
List of Xsigo devices.
Definition: xsigo.c:58
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct retry_timer discovery
Discovery timer.
Definition: xsigo.c:66
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
A Xsigo device.
Definition: xsigo.c:52
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
void ib_destroy_madx(struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx)
Destroy management transaction.
Definition: ib_mi.c:327

References xsigo_device::discovery, ib_device::gsi, ib_destroy_madx(), ib_link_ok(), xsigo_device::ibdev, xsigo_device::list, list_for_each_entry, xsigo_device::madx, NULL, start_timer_nodelay(), and stop_timer().

◆ xsigo_ib_remove()

static void xsigo_ib_remove ( struct ib_device ibdev)
static

Remove Xsigo device.

Parameters
ibdevInfiniband device

Definition at line 1778 of file xsigo.c.

1778  {
1779  struct xsigo_device *xdev;
1780  struct xsigo_device *tmp;
1781 
1782  /* Remove any attached Xsigo devices */
1783  list_for_each_entry_safe ( xdev, tmp, &xsigo_devices, list ) {
1784 
1785  /* Skip non-attached devices */
1786  if ( xdev->ibdev != ibdev )
1787  continue;
1788 
1789  /* Stop any ongoing discovery */
1790  if ( xdev->madx ) {
1791  ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
1792  xdev->madx = NULL;
1793  }
1794  stop_timer ( &xdev->discovery );
1795 
1796  /* Destroy all configuration managers */
1797  xcm_list ( xdev, NULL, 0 );
1798 
1799  /* Close Infiniband device, if applicable */
1800  if ( ! timer_running ( &xdev->opener ) )
1801  ib_close ( xdev->ibdev );
1802 
1803  /* Stop link opener */
1804  stop_timer ( &xdev->opener );
1805 
1806  /* Remove from list of devices and drop list's reference */
1807  DBGC ( xdev, "XDEV %s destroyed\n", xdev->name );
1808  list_del ( &xdev->list );
1809  ref_put ( &xdev->refcnt );
1810  }
1811 }
struct refcnt refcnt
Reference count.
Definition: xsigo.c:54
struct retry_timer opener
Link opener timer.
Definition: xsigo.c:63
#define DBGC(...)
Definition: compiler.h:505
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:461
void ib_close(struct ib_device *ibdev)
Close port.
Definition: infiniband.c:716
unsigned long tmp
Definition: linux_pci.h:53
#define list_del(list)
Delete an entry from a list.
Definition: list.h:119
struct ib_mad_transaction * madx
Discovery management transaction (if any)
Definition: xsigo.c:68
struct list_head list
List of Xsigo devices.
Definition: xsigo.c:58
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
struct retry_timer discovery
Discovery timer.
Definition: xsigo.c:66
#define list_for_each_entry_safe(pos, tmp, head, member)
Iterate over entries in a list, safe against deletion of the current entry.
Definition: list.h:458
static int xcm_list(struct xsigo_device *xdev, struct xsigo_manager_id *ids, unsigned int count)
Synchronise list of configuration managers.
Definition: xsigo.c:1416
const char * name
Device name.
Definition: xsigo.c:60
void stop_timer(struct retry_timer *timer)
Stop timer.
Definition: retry.c:117
A Xsigo device.
Definition: xsigo.c:52
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
#define ref_put(refcnt)
Drop reference to object.
Definition: refcnt.h:106
void ib_destroy_madx(struct ib_device *ibdev __unused, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx)
Destroy management transaction.
Definition: ib_mi.c:327

References DBGC, xsigo_device::discovery, ib_device::gsi, ib_close(), ib_destroy_madx(), xsigo_device::ibdev, xsigo_device::list, list_del, list_for_each_entry_safe, xsigo_device::madx, xsigo_device::name, NULL, xsigo_device::opener, ref_put, xsigo_device::refcnt, stop_timer(), tmp, and xcm_list().

◆ xsigo_net_notify()

static void xsigo_net_notify ( struct net_device netdev,
void *priv  __unused 
)
static

Handle device or link status change.

Parameters
netdevNetwork device
privPrivate data

Definition at line 1834 of file xsigo.c.

1835  {
1836  struct xsigo_device *xdev;
1837  struct ib_device *ibdev;
1838  struct xsigo_manager *xcm;
1839  struct xsigo_nic *xve;
1840  struct eoib_device *eoib;
1841 
1842  /* Send current operational state to XCM, if applicable */
1843  list_for_each_entry ( xdev, &xsigo_devices, list ) {
1844  ibdev = xdev->ibdev;
1845  list_for_each_entry ( xcm, &xdev->managers, list ) {
1846  list_for_each_entry ( xve, &xcm->nics, list ) {
1847  eoib = eoib_find ( ibdev, xve->mac );
1848  if ( ! eoib )
1849  continue;
1850  if ( eoib->netdev != netdev )
1851  continue;
1852  xsmp_tx_xve_oper ( xcm, xve, eoib );
1853  }
1854  }
1855  }
1856 }
uint8_t mac[ETH_ALEN]
MAC address.
Definition: xsigo.c:124
An EoIB device.
Definition: eoib.h:30
An Infiniband device.
Definition: infiniband.h:398
struct list_head nics
List of virtual Ethernet devices.
Definition: xsigo.c:101
struct list_head managers
List of configuration managers.
Definition: xsigo.c:71
#define list_for_each_entry(pos, head, member)
Iterate over entries in a list.
Definition: list.h:431
struct list_head list
List of EoIB devices.
Definition: eoib.h:38
struct ib_device * ibdev
Underlying Infiniband device.
Definition: xsigo.c:56
static struct net_device * netdev
Definition: gdbudp.c:52
A Xsigo configuration manager.
Definition: xsigo.c:75
struct net_device * netdev
Network device.
Definition: eoib.h:34
struct ib_device * ibdev
Underlying Infiniband device.
Definition: eoib.h:36
struct eoib_device * eoib_find(struct ib_device *ibdev, const uint8_t *hw_addr)
Find EoIB device.
Definition: eoib.c:677
A Xsigo virtual Ethernet device.
Definition: xsigo.c:113
A Xsigo device.
Definition: xsigo.c:52
static int xsmp_tx_xve_oper(struct xsigo_manager *xcm, struct xsigo_nic *xve, struct eoib_device *eoib)
Send virtual Ethernet current operational state.
Definition: xsigo.c:817

References eoib_find(), eoib_device::ibdev, xsigo_device::ibdev, eoib_device::list, list_for_each_entry, xsigo_nic::mac, xsigo_device::managers, eoib_device::netdev, netdev, xsigo_manager::nics, and xsmp_tx_xve_oper().

Variable Documentation

◆ xcm_service_id

union ib_guid xcm_service_id
static
Initial value:
= {
.bytes = XCM_SERVICE_ID,
}
#define XCM_SERVICE_ID
Xsigo configuration manager service ID.
Definition: xsigo.h:20

Configuration manager service ID.

Definition at line 130 of file xsigo.c.

Referenced by xcm_reopen().

◆ xcm_xfer_op

struct interface_operation xcm_xfer_op[]
static
Initial value:
= {
}
void xfer_window_changed(struct interface *intf)
Report change of flow control window.
Definition: xfer.c:146
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:249
static int xcm_deliver(struct xsigo_manager *xcm, struct io_buffer *iobuf, struct xfer_metadata *meta __unused)
Receive data from configuration manager.
Definition: xsigo.c:1179
A Xsigo configuration manager.
Definition: xsigo.c:75
#define INTF_OP(op_type, object_type, op_func)
Define an object interface operation.
Definition: interface.h:32
int xfer_deliver(struct interface *intf, struct io_buffer *iobuf, struct xfer_metadata *meta)
Deliver datagram.
Definition: xfer.c:194
static void xcm_close(struct xsigo_manager *xcm, int rc)
Close configuration manager connection.
Definition: xsigo.c:1113
static void xcm_step(struct xsigo_manager *xcm)
Send data to configuration manager.
Definition: xsigo.c:1135

Configuration manager data transfer interface operations.

Definition at line 1232 of file xsigo.c.

◆ xcm_xfer_desc

struct interface_descriptor xcm_xfer_desc
static
Initial value:
=
static struct interface_operation xcm_xfer_op[]
Configuration manager data transfer interface operations.
Definition: xsigo.c:1232
A Xsigo configuration manager.
Definition: xsigo.c:75
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:80

Configuration manager data transfer interface descriptor.

Definition at line 1239 of file xsigo.c.

Referenced by xcm_create().

◆ xcm_process_desc

struct process_descriptor xcm_process_desc
static
Initial value:
=
A process.
Definition: process.h:17
#define PROC_DESC_ONCE(object_type, process, _step)
Define a process descriptor for a process that runs only once.
Definition: process.h:97
A Xsigo configuration manager.
Definition: xsigo.c:75
static void xcm_step(struct xsigo_manager *xcm)
Send data to configuration manager.
Definition: xsigo.c:1135

Configuration manager process descriptor.

Definition at line 1243 of file xsigo.c.

Referenced by xcm_create().

◆ xsigo_xcm_discovery

struct xsigo_discovery xsigo_xcm_discovery
static
Initial value:
= {
.name = "manager",
.op = {
.complete = xsigo_xcm_complete,
},
}
static void xsigo_xcm_complete(struct ib_device *ibdev, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av __unused)
Handle configuration manager lookup completion.
Definition: xsigo.c:1483

Configuration manager lookup discovery stage.

Definition at line 1527 of file xsigo.c.

Referenced by xsigo_xds_complete().

◆ xsigo_xds_discovery

struct xsigo_discovery xsigo_xds_discovery
static
Initial value:
= {
.name = "directory",
.op = {
.complete = xsigo_xds_complete,
},
}
static void xsigo_xds_complete(struct ib_device *ibdev, struct ib_mad_interface *mi __unused, struct ib_mad_transaction *madx, int rc, union ib_mad *mad, struct ib_address_vector *av __unused)
Handle directory service lookup completion.
Definition: xsigo.c:1544

Directory service lookup discovery stage.

Definition at line 1635 of file xsigo.c.

Referenced by xsigo_discover().

◆ __ib_driver

struct ib_driver xsigo_ib_driver __ib_driver
Initial value:
= {
.name = "Xsigo",
.probe = xsigo_ib_probe,
.notify = xsigo_ib_notify,
.remove = xsigo_ib_remove,
}
static void xsigo_ib_notify(struct ib_device *ibdev)
Handle device or link status change.
Definition: xsigo.c:1750
static int xsigo_ib_probe(struct ib_device *ibdev)
Probe Xsigo device.
Definition: xsigo.c:1718
static void xsigo_ib_remove(struct ib_device *ibdev)
Remove Xsigo device.
Definition: xsigo.c:1778

Xsigo Infiniband driver.

Definition at line 1814 of file xsigo.c.

◆ __net_driver

struct net_driver xsigo_net_driver __net_driver
Initial value:
= {
.name = "Xsigo",
.notify = xsigo_net_notify,
}
static void xsigo_net_notify(struct net_device *netdev, void *priv __unused)
Handle device or link status change.
Definition: xsigo.c:1834

Xsigo network driver.

Definition at line 1859 of file xsigo.c.