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)
 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:597
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:362

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:447
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:420
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:98
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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:409
#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:348
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:403
An Ethernet link-layer header.
Definition: if_ether.h:30
#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:652
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:348
char name[16]
Device name.
Definition: xsigo.c:119
int netdev_open(struct net_device *netdev)
Open network device.
Definition: netdevice.c:767

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:652
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:348
char name[16]
Device name.
Definition: xsigo.c:119
void netdev_close(struct net_device *netdev)
Close network device.
Definition: netdevice.c:801

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
uint8_t type
Type.
Definition: ena.h:16
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
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:439
struct interface xfer
Data transfer interface.
Definition: xsigo.c:88
uint8_t type
Type.
Definition: ena.h:16
#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:287
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
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
#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
struct ib_gid::@532 s

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 }
uint8_t type
Type.
Definition: ena.h:16
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
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:439
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:287
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
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
struct ib_gid::@532 s

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:439
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:652
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 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:348
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:447
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:403
An Ethernet link-layer header.
Definition: if_ether.h:30
#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
struct ib_gid::@532 s

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 }
uint8_t type
Type.
Definition: ena.h:16
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
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  tca.qpn = ntohl ( msg->tca.data );
874  tca.qkey = ntohs ( msg->tca.qkey );
875  tca.gid_present = 1;
876  tca.gid.s.prefix.qword = bswap_64 ( msg->tca.prefix_le.qword );
877  tca.gid.s.guid.qword = bswap_64 ( msg->guid_le.qword );
878 
879  /* Update MTU, if applicable */
880  if ( ( update & XSMP_XVE_UPDATE_MTU ) &&
881  ( ( rc = xve_update_mtu ( xve, eoib, mtu ) ) != 0 ) )
882  goto err_mtu;
883  update &= ~XSMP_XVE_UPDATE_MTU;
884 
885  /* Update admin state, if applicable */
886  if ( ( update & XSMP_XVE_UPDATE_STATE ) &&
887  ( ( rc = xve_update_state ( xve, eoib, msg->state ) ) != 0 ) )
888  goto err_state;
889  update &= ~XSMP_XVE_UPDATE_STATE;
890 
891  /* Remove gateway, if applicable */
892  if ( ( update & XSMP_XVE_UPDATE_GW_DOWN ) &&
893  ( ( rc = xve_update_tca ( xve, eoib, NULL ) ) != 0 ) )
894  goto err_gw_down;
895  update &= ~XSMP_XVE_UPDATE_GW_DOWN;
896 
897  /* Update gateway, if applicable */
898  if ( ( update & XSMP_XVE_UPDATE_GW_CHANGE ) &&
899  ( ( rc = xve_update_tca ( xve, eoib, &tca ) ) != 0 ) )
900  goto err_gw_change;
901  update &= ~XSMP_XVE_UPDATE_GW_CHANGE;
902 
903  /* Warn about unexpected updates */
904  if ( update ) {
905  DBGC ( xve, "XVE %s unrecognised update(s) %#08x\n",
906  xve->name, update );
907  }
908 
909  xsmp_tx_xve_params ( xcm, msg, xve, eoib );
910  return 0;
911 
912  err_gw_change:
913  err_gw_down:
914  err_state:
915  err_mtu:
916  err_no_eoib:
917  err_no_xve:
918  /* Send NACK */
919  xsmp_tx_xve_nack ( xcm, msg );
920  return rc;
921 }
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:362
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 930 of file xsigo.c.

931  {
932  union {
933  struct xsmp_xve_mac msg;
935  } mac;
936  char name[ sizeof ( msg->name ) + 1 /* NUL */ ];
937  unsigned long network;
938  unsigned long qkey;
939  unsigned int update;
940  int rc;
941 
942  /* Demangle MAC address (which is erroneously transmitted as
943  * little-endian).
944  */
945  mac.msg.high = bswap_16 ( msg->mac_le.high );
946  mac.msg.low = bswap_32 ( msg->mac_le.low );
947 
948  /* Extract interface name (which may not be NUL-terminated) */
949  memcpy ( name, msg->name, ( sizeof ( name ) - 1 /* NUL */ ) );
950  name[ sizeof ( name ) - 1 /* NUL */ ] = '\0';
951 
952  /* Extract remaining message parameters */
953  network = ntohl ( msg->network );
954  qkey = ntohs ( msg->tca.qkey );
955  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " install \"%s\" %s net %ld qkey "
956  "%#lx\n", xcm->name, IB_GUID_ARGS ( &msg->resource ), name,
957  eth_ntoa ( mac.raw ), network, qkey );
958 
959  /* Create virtual Ethernet device, if applicable */
960  if ( ( xve_find ( xcm, &msg->resource ) == NULL ) &&
961  ( ( rc = xve_create ( xcm, &msg->resource, mac.raw, network,
962  qkey, name ) ) != 0 ) )
963  goto err_create;
964 
965  /* Handle remaining parameters as for a modification message */
966  update = XSMP_XVE_UPDATE_MTU;
967  if ( msg->uplink == XSMP_XVE_UPLINK )
968  update |= XSMP_XVE_UPDATE_GW_CHANGE;
969  return xsmp_rx_xve_modify ( xcm, msg, update );
970 
971  err_create:
972  /* Send NACK */
973  xsmp_tx_xve_nack ( xcm, msg );
974  return rc;
975 }
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:362
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 984 of file xsigo.c.

985  {
986  struct xsigo_nic *xve;
987 
988  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " delete\n",
989  xcm->name, IB_GUID_ARGS ( &msg->resource ) );
990 
991  /* Destroy virtual Ethernet device (if any) */
992  if ( ( xve = xve_find ( xcm, &msg->resource ) ) )
993  xve_destroy ( xve );
994 
995  /* Send ACK */
996  msg->code = 0;
997  xsmp_tx_xve ( xcm, msg );
998 
999  return 0;
1000 }
#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 1009 of file xsigo.c.

1010  {
1011  unsigned int update = ntohl ( msg->update );
1012 
1013  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " update (%08x)\n",
1014  xcm->name, IB_GUID_ARGS ( &msg->resource ), update );
1015 
1016  /* Handle as a modification message */
1017  return xsmp_rx_xve_modify ( xcm, msg, update );
1018 }
#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 1027 of file xsigo.c.

1028  {
1029 
1030  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " operational request\n",
1031  xcm->name, IB_GUID_ARGS ( &msg->resource ) );
1032 
1033  /* Handle as a nullipotent modification message */
1034  return xsmp_rx_xve_modify ( xcm, msg, 0 );
1035 }
#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 1044 of file xsigo.c.

1045  {
1046  int rc;
1047 
1048  DBGC2 ( xcm, "XCM %s " IB_GUID_FMT " ready\n",
1049  xcm->name, IB_GUID_ARGS ( &msg->resource ) );
1050 
1051  /* Handle as a nullipotent modification message */
1052  if ( ( rc = xsmp_rx_xve_modify ( xcm, msg, 0 ) ) != 0 )
1053  return rc;
1054 
1055  /* Send an unsolicited operational state update, since there
1056  * is no other way to convey the current operational state.
1057  */
1058  msg->type = XSMP_XVE_TYPE_OPER_REQ;
1059  if ( ( rc = xsmp_rx_xve_modify ( xcm, msg, 0 ) ) != 0 )
1060  return rc;
1061 
1062  return 0;
1063 }
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 1072 of file xsigo.c.

1073  {
1074 
1075  DBGCP ( xcm, "XCM %s RX[%d] xve %s\n", xcm->name,
1076  ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ) );
1077  DBGCP_HDA ( xcm, 0, msg, sizeof ( *msg ) );
1078 
1079  /* Handle message according to type */
1080  switch ( msg->type ) {
1081  case XSMP_XVE_TYPE_INSTALL:
1082  return xsmp_rx_xve_install ( xcm, msg );
1083  case XSMP_XVE_TYPE_DELETE:
1084  return xsmp_rx_xve_delete ( xcm, msg );
1085  case XSMP_XVE_TYPE_UPDATE:
1086  return xsmp_rx_xve_update ( xcm, msg );
1088  return xsmp_rx_xve_oper_req ( xcm, msg );
1089  case XSMP_XVE_TYPE_READY:
1090  return xsmp_rx_xve_ready ( xcm, msg );
1091  default:
1092  DBGC ( xcm, "XCM %s RX[%d] xve unexpected %s:\n", xcm->name,
1093  ntohl ( msg->hdr.seq ), xsmp_xve_type ( msg->type ) );
1094  DBGC_HDA ( xcm, 0, msg, sizeof ( *msg ) );
1095  return -EPROTO;
1096  }
1097 }
#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:930
#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:984
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:1009
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:1027
#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:1044
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 1112 of file xsigo.c.

1112  {
1113 
1114  DBGC ( xcm, "XCM %s closed: %s\n", xcm->name, strerror ( rc ) );
1115 
1116  /* Stop transmission process */
1117  process_del ( &xcm->process );
1118 
1119  /* Stop keepalive timer */
1120  stop_timer ( &xcm->keepalive );
1121 
1122  /* Restart data transfer interface */
1123  intf_restart ( &xcm->xfer, rc );
1124 
1125  /* Schedule reconnection attempt */
1126  start_timer ( &xcm->reopen );
1127 }
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:337
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 1134 of file xsigo.c.

1134  {
1135  int rc;
1136 
1137  /* Do nothing unless we have something to send */
1138  if ( ! xcm->pending )
1139  return;
1140 
1141  /* Send (empty) connection request, if applicable */
1142  if ( xcm->pending & XCM_TX_CONNECT ) {
1143  if ( ( rc = xfer_deliver_raw ( &xcm->xfer, NULL, 0 ) ) != 0 ) {
1144  DBGC ( xcm, "XCM %s could not send connection request: "
1145  "%s\n", xcm->name, strerror ( rc ) );
1146  goto err;
1147  }
1148  xcm->pending &= ~XCM_TX_CONNECT;
1149  return;
1150  }
1151 
1152  /* Wait until data transfer interface is connected */
1153  if ( ! xfer_window ( &xcm->xfer ) )
1154  return;
1155 
1156  /* Send registration message, if applicable */
1157  if ( xcm->pending & XCM_TX_REGISTER ) {
1158  if ( ( rc = xsmp_tx_session_register ( xcm ) ) != 0 )
1159  goto err;
1161  return;
1162  }
1163 
1164  return;
1165 
1166  err:
1167  xcm_close ( xcm, rc );
1168 }
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:115
int xfer_deliver_raw(struct interface *intf, const void *data, size_t len)
Deliver datagram as raw data without metadata.
Definition: xfer.c:287
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:1112
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
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 1178 of file xsigo.c.

1179  {
1180  union xsmp_message *msg;
1181  size_t len = iob_len ( iobuf );
1182  int rc;
1183 
1184  /* Sanity check */
1185  if ( len < sizeof ( msg->hdr ) ) {
1186  DBGC ( xcm, "XCM %s underlength message:\n", xcm->name );
1187  DBGC_HDA ( xcm, 0, iobuf->data, iob_len ( iobuf ) );
1188  rc = -EPROTO;
1189  goto out;
1190  }
1191  msg = iobuf->data;
1192 
1193  /* Handle message according to type */
1194  if ( ! msg->hdr.type ) {
1195 
1196  /* Ignore unused communication manager private data blocks */
1197  rc = 0;
1198 
1199  } else if ( ( msg->hdr.type == XSMP_TYPE_SESSION ) &&
1200  ( len >= sizeof ( msg->sess ) ) ) {
1201 
1202  /* Session message */
1203  rc = xsmp_rx_session ( xcm, &msg->sess );
1204 
1205  } else if ( ( msg->hdr.type == XSMP_TYPE_XVE ) &&
1206  ( len >= sizeof ( msg->xve ) ) ) {
1207 
1208  /* Virtual Ethernet message */
1209  xsmp_rx_xve ( xcm, &msg->xve );
1210 
1211  /* Virtual Ethernet message errors are non-fatal */
1212  rc = 0;
1213 
1214  } else {
1215 
1216  /* Unknown message */
1217  DBGC ( xcm, "XCM %s unexpected message type %d:\n",
1218  xcm->name, msg->hdr.type );
1219  DBGC_HDA ( xcm, 0, iobuf->data, iob_len ( iobuf ) );
1220  rc = -EPROTO;
1221  }
1222 
1223  out:
1224  free_iob ( iobuf );
1225  if ( rc != 0 )
1226  xcm_close ( xcm, rc );
1227  return rc;
1228 }
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:145
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
char name[16]
Device name.
Definition: xsigo.c:83
#define DBGC_HDA(...)
Definition: compiler.h:506
__be32 out[4]
Definition: CIB_PRM.h:36
#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:151
static void xcm_close(struct xsigo_manager *xcm, int rc)
Close configuration manager connection.
Definition: xsigo.c:1112
static int xsmp_rx_xve(struct xsigo_manager *xcm, struct xsmp_xve_message *msg)
Handle received virtual Ethernet message.
Definition: xsigo.c:1072
uint32_t len
Length.
Definition: ena.h:14
void * data
Start of data.
Definition: iobuf.h:44
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 1251 of file xsigo.c.

1251  {
1252  struct xsigo_manager *xcm =
1253  container_of ( timer, struct xsigo_manager, reopen );
1254  struct xsigo_device *xdev = xcm->xdev;
1255  struct ib_device *ibdev = xdev->ibdev;
1256  union ib_gid gid;
1257  int rc;
1258 
1259  /* Stop transmission process */
1260  process_del ( &xcm->process );
1261 
1262  /* Stop keepalive timer */
1263  stop_timer ( &xcm->keepalive );
1264 
1265  /* Restart data transfer interface */
1266  intf_restart ( &xcm->xfer, -ECANCELED );
1267 
1268  /* Reset sequence number */
1269  xcm->seq = 0;
1270 
1271  /* Construct GID */
1272  memcpy ( &gid.s.prefix, &ibdev->gid.s.prefix, sizeof ( gid.s.prefix ) );
1273  memcpy ( &gid.s.guid, &xcm->id.guid, sizeof ( gid.s.guid ) );
1274  DBGC ( xcm, "XCM %s connecting to " IB_GID_FMT "\n",
1275  xcm->name, IB_GID_ARGS ( &gid ) );
1276 
1277  /* Open CMRC connection */
1278  if ( ( rc = ib_cmrc_open ( &xcm->xfer, ibdev, &gid,
1279  &xcm_service_id, xcm->name ) ) != 0 ) {
1280  DBGC ( xcm, "XCM %s could not open CMRC connection: %s\n",
1281  xcm->name, strerror ( rc ) );
1282  start_timer ( &xcm->reopen );
1283  return;
1284  }
1285 
1286  /* Schedule transmissions */
1287  xcm->pending |= ( XCM_TX_CONNECT | XCM_TX_REGISTER );
1288  process_add ( &xcm->process );
1289 
1290  /* Start keepalive timer */
1292 
1293  return;
1294 }
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:337
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:439
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
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
struct ib_gid::@532 s

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 1302 of file xsigo.c.

1302  {
1303  struct xsigo_manager *xcm =
1305  int rc;
1306 
1307  /* Send keepalive message. The server won't actually respond
1308  * to these, but it gives the RC queue pair a chance to
1309  * complain if it doesn't ever at least get an ACK.
1310  */
1311  if ( ( rc = xsmp_tx_session_hello ( xcm ) ) != 0 ) {
1312  xcm_close ( xcm, rc );
1313  return;
1314  }
1315 
1316  /* Restart keepalive timer */
1318 }
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:1112
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 1327 of file xsigo.c.

1328  {
1329  struct xsigo_manager *xcm;
1330 
1331  /* Allocate and initialise structure */
1332  xcm = zalloc ( sizeof ( *xcm ) );
1333  if ( ! xcm )
1334  return -ENOMEM;
1335  ref_init ( &xcm->refcnt, xcm_free );
1336  xcm->xdev = xdev;
1337  ref_get ( &xcm->xdev->refcnt );
1338  snprintf ( xcm->name, sizeof ( xcm->name ), "%s:xcm-%d",
1339  xdev->name, ntohs ( id->lid ) );
1340  memcpy ( &xcm->id, id, sizeof ( xcm->id ) );
1341  intf_init ( &xcm->xfer, &xcm_xfer_desc, &xcm->refcnt );
1342  timer_init ( &xcm->keepalive, xcm_keepalive, &xcm->refcnt );
1343  timer_init ( &xcm->reopen, xcm_reopen, &xcm->refcnt );
1345  INIT_LIST_HEAD ( &xcm->nics );
1346 
1347  /* Start timer to open connection */
1348  start_timer_nodelay ( &xcm->reopen );
1349 
1350  /* Add to list of managers and transfer reference to list */
1351  list_add ( &xcm->list, &xdev->managers );
1352  DBGC ( xcm, "XCM %s created for " IB_GUID_FMT " (LID %d)\n", xcm->name,
1353  IB_GUID_ARGS ( &xcm->id.guid ), ntohs ( id->lid ) );
1354  return 0;
1355 }
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:1302
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:1251
static struct interface_descriptor xcm_xfer_desc
Configuration manager data transfer interface descriptor.
Definition: xsigo.c:1238
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:1242
#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:173

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 1364 of file xsigo.c.

1365  {
1366  struct xsigo_manager *xcm;
1367  union ib_guid *guid = &id->guid;
1368 
1369  /* Find configuration manager */
1370  list_for_each_entry ( xcm, &xdev->managers, list ) {
1371  if ( memcmp ( guid, &xcm->id.guid, sizeof ( *guid ) ) == 0 )
1372  return xcm;
1373  }
1374  return NULL;
1375 }
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:420
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:98
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362

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 1382 of file xsigo.c.

1382  {
1383  struct xsigo_nic *xve;
1384 
1385  /* Remove all EoIB NICs */
1386  while ( ( xve = list_first_entry ( &xcm->nics, struct xsigo_nic,
1387  list ) ) ) {
1388  xve_destroy ( xve );
1389  }
1390 
1391  /* Stop transmission process */
1392  process_del ( &xcm->process );
1393 
1394  /* Stop timers */
1395  stop_timer ( &xcm->keepalive );
1396  stop_timer ( &xcm->reopen );
1397 
1398  /* Shut down data transfer interface */
1399  intf_shutdown ( &xcm->xfer, 0 );
1400 
1401  /* Remove from list of managers and drop list's reference */
1402  DBGC ( xcm, "XCM %s destroyed\n", xcm->name );
1403  list_del ( &xcm->list );
1404  ref_put ( &xcm->refcnt );
1405 }
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:273
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 1415 of file xsigo.c.

1416  {
1417  struct xsigo_manager_id *id;
1418  struct xsigo_manager *xcm;
1419  struct xsigo_manager *tmp;
1420  struct list_head list;
1421  unsigned int i;
1422  int rc;
1423 
1424  /* Create list of managers to be retained */
1425  INIT_LIST_HEAD ( &list );
1426  for ( i = 0, id = ids ; i < count ; i++, id++ ) {
1427  if ( ( xcm = xcm_find ( xdev, id ) ) ) {
1428  list_del ( &xcm->list );
1429  list_add_tail ( &xcm->list, &list );
1430  }
1431  }
1432 
1433  /* Destroy any managers not in the list */
1434  list_for_each_entry_safe ( xcm, tmp, &xdev->managers, list )
1435  xcm_destroy ( xcm );
1436  list_splice ( &list, &xdev->managers );
1437 
1438  /* Create any new managers in the list, and force reconnection
1439  * for any changed LIDs.
1440  */
1441  for ( i = 0, id = ids ; i < count ; i++, id++ ) {
1442  if ( ( xcm = xcm_find ( xdev, id ) ) ) {
1443  if ( xcm->id.lid != id->lid )
1444  start_timer_nodelay ( &xcm->reopen );
1445  continue;
1446  }
1447  if ( ( rc = xcm_create ( xdev, id ) ) != 0 ) {
1448  DBGC ( xdev, "XDEV %s could not create manager: %s\n",
1449  xdev->name, strerror ( rc ) );
1450  return rc;
1451  }
1452  }
1453 
1454  return 0;
1455 }
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
static void xcm_destroy(struct xsigo_manager *xcm)
Destroy configuration manager.
Definition: xsigo.c:1382
static void start_timer_nodelay(struct retry_timer *timer)
Start timer with no delay.
Definition: retry.h:99
static int xcm_create(struct xsigo_device *xdev, struct xsigo_manager_id *id)
Create configuration manager.
Definition: xsigo.c:1327
#define DBGC(...)
Definition: compiler.h:505
static const char grant_ref_t unsigned int struct io_buffer grant_ref_t uint8_t * ids
Definition: netfront.h:94
A doubly-linked list entry (or list head)
Definition: list.h:18
#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:1364
#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:447
uint8_t id
Request identifier.
Definition: ena.h:12
char * strerror(int errno)
Retrieve string representation of error number.
Definition: strerror.c:78
uint8_t * tmp
Definition: entropy.h:156
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 1482 of file xsigo.c.

1486  {
1487  struct xsigo_device *xdev = ib_madx_get_ownerdata ( madx );
1488  union xsigo_mad *xsmad = container_of ( mad, union xsigo_mad, mad );
1489  struct xsigo_managers_reply *reply = &xsmad->reply;
1490 
1491  /* Check for failures */
1492  if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) )
1493  rc = -ENODEV;
1494  if ( rc != 0 ) {
1495  DBGC ( xdev, "XDEV %s manager lookup failed: %s\n",
1496  xdev->name, strerror ( rc ) );
1497  goto out;
1498  }
1499 
1500  /* Sanity checks */
1501  if ( reply->count > ( sizeof ( reply->manager ) /
1502  sizeof ( reply->manager[0] ) ) ) {
1503  DBGC ( xdev, "XDEV %s has too many managers (%d)\n",
1504  xdev->name, reply->count );
1505  goto out;
1506  }
1507 
1508  /* Synchronise list of managers */
1509  if ( ( rc = xcm_list ( xdev, reply->manager, reply->count ) ) != 0 )
1510  goto out;
1511 
1512  /* Report an empty list of managers */
1513  if ( reply->count == 0 )
1514  DBGC ( xdev, "XDEV %s has no managers\n", xdev->name );
1515 
1516  /* Delay next discovery attempt */
1518 
1519 out:
1520  /* Destroy the completed transaction */
1521  ib_destroy_madx ( ibdev, ibdev->gsi, madx );
1522  xdev->madx = NULL;
1523 }
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:459
#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
__be32 out[4]
Definition: CIB_PRM.h:36
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:1415
#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:362
#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 1543 of file xsigo.c.

1547  {
1548  struct xsigo_device *xdev = ib_madx_get_ownerdata ( madx );
1549  union xsigo_mad *xsmad = container_of ( mad, union xsigo_mad, mad );
1550  struct xsigo_managers_request *request = &xsmad->request;
1551  struct ib_service_record *svc;
1552  struct ib_address_vector dest;
1553  union ib_guid *guid;
1554 
1555  /* Allow for reuse of transaction pointer */
1556  xdev->madx = NULL;
1557 
1558  /* Check for failures */
1559  if ( ( rc == 0 ) && ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) )
1560  rc = -ENODEV;
1561  if ( rc != 0 ) {
1562  DBGC ( xdev, "XDEV %s directory lookup failed: %s\n",
1563  xdev->name, strerror ( rc ) );
1564  goto out;
1565  }
1566 
1567  /* Construct address vector */
1568  memset ( &dest, 0, sizeof ( dest ) );
1569  svc = &mad->sa.sa_data.service_record;
1570  dest.lid = ntohs ( svc->data16[0] );
1571  dest.sl = ibdev->sm_sl;
1572  dest.qpn = IB_QPN_GSI;
1573  dest.qkey = IB_QKEY_GSI;
1574  guid = ( ( union ib_guid * ) &svc->data64[0] );
1575  DBGC2 ( xdev, "XDEV %s found directory at LID %d GUID " IB_GUID_FMT
1576  "\n", xdev->name, dest.lid, IB_GUID_ARGS ( guid ) );
1577 
1578  /* Construct request (reusing MAD buffer) */
1579  memset ( request, 0, sizeof ( *request ) );
1580  request->mad_hdr.mgmt_class = XSIGO_MGMT_CLASS;
1581  request->mad_hdr.class_version = XSIGO_MGMT_CLASS_VERSION;
1582  request->mad_hdr.method = IB_MGMT_METHOD_GET;
1583  request->mad_hdr.attr_id = htons ( XSIGO_ATTR_XCM_REQUEST );
1584  memcpy ( &request->server.guid, &ibdev->gid.s.guid,
1585  sizeof ( request->server.guid ) );
1586  snprintf ( request->os_version, sizeof ( request->os_version ),
1587  "%s %s", product_short_name, product_version );
1588  snprintf ( request->arch, sizeof ( request->arch ), _S2 ( ARCH ) );
1589  request->os_type = XSIGO_OS_TYPE_GENERIC;
1590  request->resources = htons ( XSIGO_RESOURCES_PRESENT |
1593 
1594  /* The handling of this request on the server side is a
1595  * textbook example of how not to design a wire protocol. The
1596  * server uses the _driver_ version number to determine which
1597  * fields are present.
1598  */
1599  request->driver_version = htonl ( 0x2a2a2a );
1600 
1601  /* The build version field is ignored unless it happens to
1602  * contain the substring "xg-".
1603  */
1604  snprintf ( request->build, sizeof ( request->build ),
1605  "not-xg-%08lx", build_id );
1606 
1607  /* The server side user interface occasionally has no way to
1608  * refer to an entry with an empty hostname.
1609  */
1610  fetch_string_setting ( NULL, &hostname_setting, request->hostname,
1611  sizeof ( request->hostname ) );
1612  if ( ! request->hostname[0] ) {
1613  snprintf ( request->hostname, sizeof ( request->hostname ),
1615  IB_GUID_ARGS ( &ibdev->gid.s.guid ) );
1616  }
1617 
1618  /* Start configuration manager lookup */
1619  xdev->madx = ib_create_madx ( ibdev, ibdev->gsi, mad, &dest,
1621  if ( ! xdev->madx ) {
1622  DBGC ( xdev, "XDEV %s could not start manager lookup\n",
1623  xdev->name );
1624  goto out;
1625  }
1626  ib_madx_set_ownerdata ( xdev->madx, xdev );
1627 
1628 out:
1629  /* Destroy the completed transaction */
1630  ib_destroy_madx ( ibdev, ibdev->gsi, madx );
1631 }
const char product_short_name[]
Product short name string.
Definition: version.c:75
#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:439
#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:1526
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:459
#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
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:60
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
__be32 out[4]
Definition: CIB_PRM.h:36
int fetch_string_setting(struct settings *settings, const struct setting *setting, char *data, size_t len)
Fetch value of string setting.
Definition: settings.c:845
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:445
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:69
#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:1469
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:362
#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
struct ib_gid::@532 s

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 1647 of file xsigo.c.

1647  {
1648  struct xsigo_device *xdev =
1650  struct ib_device *ibdev = xdev->ibdev;
1651  struct xsigo_discovery *discovery;
1652 
1653  /* Restart timer */
1655 
1656  /* Cancel any pending discovery transaction */
1657  if ( xdev->madx ) {
1658  discovery = container_of ( xdev->madx->op,
1659  struct xsigo_discovery, op );
1660  DBGC ( xdev, "XDEV %s timed out waiting for %s lookup\n",
1661  xdev->name, discovery->name );
1662  ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
1663  xdev->madx = NULL;
1664  }
1665 
1666  /* Start directory service lookup */
1667  xdev->madx = ib_create_service_madx ( ibdev, ibdev->gsi,
1670  if ( ! xdev->madx ) {
1671  DBGC ( xdev, "XDEV %s could not start directory lookup\n",
1672  xdev->name );
1673  return;
1674  }
1675  ib_madx_set_ownerdata ( xdev->madx, xdev );
1676 }
#define DBGC(...)
Definition: compiler.h:505
static struct xsigo_discovery xsigo_xds_discovery
Directory service lookup discovery stage.
Definition: xsigo.c:1634
struct ib_mad_interface * gsi
General services interface.
Definition: infiniband.h:459
A stage of discovery.
Definition: xsigo.c:1465
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:1469
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:1467
A Xsigo device.
Definition: xsigo.c:52
#define NULL
NULL pointer (VOID *)
Definition: Base.h:362
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 1691 of file xsigo.c.

1691  {
1692  struct xsigo_device *xdev =
1693  container_of ( opener, struct xsigo_device, opener );
1694  struct ib_device *ibdev = xdev->ibdev;
1695  int rc;
1696 
1697  /* Open Infiniband device */
1698  if ( ( rc = ib_open ( ibdev ) ) != 0 ) {
1699  DBGC ( xdev, "XDEV %s could not open: %s\n",
1700  xdev->name, strerror ( rc ) );
1701  /* Delay and try again */
1703  return;
1704  }
1705 
1706  /* If link is already up, then start discovery */
1707  if ( ib_link_ok ( ibdev ) )
1708  start_timer_nodelay ( &xdev->discovery );
1709 }
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:564
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 1717 of file xsigo.c.

1717  {
1718  struct xsigo_device *xdev;
1719 
1720  /* Allocate and initialise structure */
1721  xdev = zalloc ( sizeof ( *xdev ) );
1722  if ( ! xdev )
1723  return -ENOMEM;
1724  ref_init ( &xdev->refcnt, xsigo_free );
1725  xdev->ibdev = ibdev_get ( ibdev );
1726  xdev->name = ibdev->name;
1727  timer_init ( &xdev->opener, xsigo_ib_open, &xdev->refcnt );
1728  timer_init ( &xdev->discovery, xsigo_discover, &xdev->refcnt );
1729  INIT_LIST_HEAD ( &xdev->managers );
1730 
1731  /* Start timer to open Infiniband device. (We are currently
1732  * within the Infiniband device probe callback list; opening
1733  * the device here would have interesting side-effects.)
1734  */
1735  start_timer_nodelay ( &xdev->opener );
1736 
1737  /* Add to list of devices and transfer reference to list */
1738  list_add_tail ( &xdev->list, &xsigo_devices );
1739  DBGC ( xdev, "XDEV %s created for " IB_GUID_FMT "\n",
1740  xdev->name, IB_GUID_ARGS ( &ibdev->gid.s.guid ) );
1741  return 0;
1742 }
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:439
#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:1691
#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:586
#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 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:1647
struct ib_gid::@532 s

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 1749 of file xsigo.c.

1749  {
1750  struct xsigo_device *xdev;
1751 
1752  /* Stop/restart discovery on any attached devices */
1753  list_for_each_entry ( xdev, &xsigo_devices, list ) {
1754 
1755  /* Skip non-attached devices */
1756  if ( xdev->ibdev != ibdev )
1757  continue;
1758 
1759  /* Stop any ongoing discovery */
1760  if ( xdev->madx ) {
1761  ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
1762  xdev->madx = NULL;
1763  }
1764  stop_timer ( &xdev->discovery );
1765 
1766  /* If link is up, then start discovery */
1767  if ( ib_link_ok ( ibdev ) )
1768  start_timer_nodelay ( &xdev->discovery );
1769  }
1770 }
static __always_inline int ib_link_ok(struct ib_device *ibdev)
Check link state of Infiniband device.
Definition: infiniband.h:564
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:459
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:420
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:362
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 1777 of file xsigo.c.

1777  {
1778  struct xsigo_device *xdev;
1779  struct xsigo_device *tmp;
1780 
1781  /* Remove any attached Xsigo devices */
1782  list_for_each_entry_safe ( xdev, tmp, &xsigo_devices, list ) {
1783 
1784  /* Skip non-attached devices */
1785  if ( xdev->ibdev != ibdev )
1786  continue;
1787 
1788  /* Stop any ongoing discovery */
1789  if ( xdev->madx ) {
1790  ib_destroy_madx ( ibdev, ibdev->gsi, xdev->madx );
1791  xdev->madx = NULL;
1792  }
1793  stop_timer ( &xdev->discovery );
1794 
1795  /* Destroy all configuration managers */
1796  xcm_list ( xdev, NULL, 0 );
1797 
1798  /* Close Infiniband device, if applicable */
1799  if ( ! timer_running ( &xdev->opener ) )
1800  ib_close ( xdev->ibdev );
1801 
1802  /* Stop link opener */
1803  stop_timer ( &xdev->opener );
1804 
1805  /* Remove from list of devices and drop list's reference */
1806  DBGC ( xdev, "XDEV %s destroyed\n", xdev->name );
1807  list_del ( &xdev->list );
1808  ref_put ( &xdev->refcnt );
1809  }
1810 }
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:459
void ib_close(struct ib_device *ibdev)
Close port.
Definition: infiniband.c:716
#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:447
static int xcm_list(struct xsigo_device *xdev, struct xsigo_manager_id *ids, unsigned int count)
Synchronise list of configuration managers.
Definition: xsigo.c:1415
uint8_t * tmp
Definition: entropy.h:156
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:362
#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)
static

Handle device or link status change.

Parameters
netdevNetwork device

Definition at line 1832 of file xsigo.c.

1832  {
1833  struct xsigo_device *xdev;
1834  struct ib_device *ibdev;
1835  struct xsigo_manager *xcm;
1836  struct xsigo_nic *xve;
1837  struct eoib_device *eoib;
1838 
1839  /* Send current operational state to XCM, if applicable */
1840  list_for_each_entry ( xdev, &xsigo_devices, list ) {
1841  ibdev = xdev->ibdev;
1842  list_for_each_entry ( xcm, &xdev->managers, list ) {
1843  list_for_each_entry ( xve, &xcm->nics, list ) {
1844  eoib = eoib_find ( ibdev, xve->mac );
1845  if ( ! eoib )
1846  continue;
1847  if ( eoib->netdev != netdev )
1848  continue;
1849  xsmp_tx_xve_oper ( xcm, xve, eoib );
1850  }
1851  }
1852  }
1853 }
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:420
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:145
void intf_close(struct interface *intf, int rc)
Close an object interface.
Definition: interface.c:244
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:1178
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:193
static void xcm_close(struct xsigo_manager *xcm, int rc)
Close configuration manager connection.
Definition: xsigo.c:1112
static void xcm_step(struct xsigo_manager *xcm)
Send data to configuration manager.
Definition: xsigo.c:1134

Configuration manager data transfer interface operations.

Definition at line 1231 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:1231
A Xsigo configuration manager.
Definition: xsigo.c:75
#define INTF_DESC(object_type, intf, operations)
Define an object interface descriptor.
Definition: interface.h:65

Configuration manager data transfer interface descriptor.

Definition at line 1238 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:1134

Configuration manager process descriptor.

Definition at line 1242 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:1482

Configuration manager lookup discovery stage.

Definition at line 1526 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:1543

Directory service lookup discovery stage.

Definition at line 1634 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:1749
static int xsigo_ib_probe(struct ib_device *ibdev)
Probe Xsigo device.
Definition: xsigo.c:1717
static void xsigo_ib_remove(struct ib_device *ibdev)
Remove Xsigo device.
Definition: xsigo.c:1777

Xsigo Infiniband driver.

Definition at line 1813 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)
Handle device or link status change.
Definition: xsigo.c:1832

Xsigo network driver.

Definition at line 1856 of file xsigo.c.