15
15
* You should have received a copy of the GNU General Public License
16
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20
21
FILE_LICENCE ( GPL2_OR_LATER );
1371
1374
static __attribute__ (( unused )) unsigned int
1372
1375
hermon_fill_nop_send_wqe ( struct ib_device *ibdev __unused,
1373
1376
struct ib_queue_pair *qp __unused,
1374
struct ib_address_vector *av __unused,
1377
struct ib_address_vector *dest __unused,
1375
1378
struct io_buffer *iobuf __unused,
1376
1379
union hermon_send_wqe *wqe ) {
1393
1396
static unsigned int
1394
1397
hermon_fill_ud_send_wqe ( struct ib_device *ibdev,
1395
1398
struct ib_queue_pair *qp __unused,
1396
struct ib_address_vector *av,
1399
struct ib_address_vector *dest,
1397
1400
struct io_buffer *iobuf,
1398
1401
union hermon_send_wqe *wqe ) {
1399
1402
struct hermon *hermon = ib_get_drvdata ( ibdev );
1405
1408
ud_address_vector.pd, HERMON_GLOBAL_PD,
1406
1409
ud_address_vector.port_number, ibdev->port );
1407
1410
MLX_FILL_2 ( &wqe->ud.ud, 1,
1408
ud_address_vector.rlid, av->lid,
1409
ud_address_vector.g, av->gid_present );
1411
ud_address_vector.rlid, dest->lid,
1412
ud_address_vector.g, dest->gid_present );
1410
1413
MLX_FILL_1 ( &wqe->ud.ud, 2,
1411
ud_address_vector.max_stat_rate, hermon_rate ( av ) );
1412
MLX_FILL_1 ( &wqe->ud.ud, 3, ud_address_vector.sl, av->sl );
1413
memcpy ( &wqe->ud.ud.u.dwords[4], &av->gid, sizeof ( av->gid ) );
1414
MLX_FILL_1 ( &wqe->ud.ud, 8, destination_qp, av->qpn );
1415
MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, av->qkey );
1414
ud_address_vector.max_stat_rate, hermon_rate ( dest ) );
1415
MLX_FILL_1 ( &wqe->ud.ud, 3, ud_address_vector.sl, dest->sl );
1416
memcpy ( &wqe->ud.ud.u.dwords[4], &dest->gid, sizeof ( dest->gid ) );
1417
MLX_FILL_1 ( &wqe->ud.ud, 8, destination_qp, dest->qpn );
1418
MLX_FILL_1 ( &wqe->ud.ud, 9, q_key, dest->qkey );
1416
1419
MLX_FILL_1 ( &wqe->ud.data[0], 0, byte_count, iob_len ( iobuf ) );
1417
1420
MLX_FILL_1 ( &wqe->ud.data[0], 1, l_key, hermon->lkey );
1418
1421
MLX_FILL_H ( &wqe->ud.data[0], 2,
1435
1438
static unsigned int
1436
1439
hermon_fill_mlx_send_wqe ( struct ib_device *ibdev,
1437
1440
struct ib_queue_pair *qp,
1438
struct ib_address_vector *av,
1441
struct ib_address_vector *dest,
1439
1442
struct io_buffer *iobuf,
1440
1443
union hermon_send_wqe *wqe ) {
1441
1444
struct hermon *hermon = ib_get_drvdata ( ibdev );
1445
1448
iob_populate ( &headers, &wqe->mlx.headers, 0,
1446
1449
sizeof ( wqe->mlx.headers ) );
1447
1450
iob_reserve ( &headers, sizeof ( wqe->mlx.headers ) );
1448
ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), av );
1451
ib_push ( ibdev, &headers, qp, iob_len ( iobuf ), dest );
1450
1453
/* Fill work queue entry */
1451
1454
MLX_FILL_1 ( &wqe->mlx.ctrl, 1, ds,
1453
1456
MLX_FILL_5 ( &wqe->mlx.ctrl, 2,
1454
1457
c, 0x03 /* generate completion */,
1455
1458
icrc, 0 /* generate ICRC */,
1456
max_statrate, hermon_rate ( av ),
1459
max_statrate, hermon_rate ( dest ),
1458
1461
v15, ( ( qp->ext_qpn == IB_QPN_SMI ) ? 1 : 0 ) );
1459
MLX_FILL_1 ( &wqe->mlx.ctrl, 3, rlid, av->lid );
1462
MLX_FILL_1 ( &wqe->mlx.ctrl, 3, rlid, dest->lid );
1460
1463
MLX_FILL_1 ( &wqe->mlx.data[0], 0,
1461
1464
byte_count, iob_len ( &headers ) );
1462
1465
MLX_FILL_1 ( &wqe->mlx.data[0], 1, l_key, hermon->lkey );
1487
1490
static unsigned int
1488
1491
hermon_fill_rc_send_wqe ( struct ib_device *ibdev,
1489
1492
struct ib_queue_pair *qp __unused,
1490
struct ib_address_vector *av __unused,
1493
struct ib_address_vector *dest __unused,
1491
1494
struct io_buffer *iobuf,
1492
1495
union hermon_send_wqe *wqe ) {
1493
1496
struct hermon *hermon = ib_get_drvdata ( ibdev );
1517
1520
static unsigned int
1518
1521
hermon_fill_eth_send_wqe ( struct ib_device *ibdev,
1519
1522
struct ib_queue_pair *qp __unused,
1520
struct ib_address_vector *av __unused,
1523
struct ib_address_vector *dest __unused,
1521
1524
struct io_buffer *iobuf,
1522
1525
union hermon_send_wqe *wqe ) {
1523
1526
struct hermon *hermon = ib_get_drvdata ( ibdev );
1542
1545
static unsigned int
1543
1546
( * hermon_fill_send_wqe[] ) ( struct ib_device *ibdev,
1544
1547
struct ib_queue_pair *qp,
1545
struct ib_address_vector *av,
1548
struct ib_address_vector *dest,
1546
1549
struct io_buffer *iobuf,
1547
1550
union hermon_send_wqe *wqe ) = {
1548
1551
[IB_QPT_SMI] = hermon_fill_mlx_send_wqe,
1558
1561
* @v ibdev Infiniband device
1559
1562
* @v qp Queue pair
1560
* @v av Address vector
1563
* @v dest Destination address vector
1561
1564
* @v iobuf I/O buffer
1562
1565
* @ret rc Return status code
1564
1567
static int hermon_post_send ( struct ib_device *ibdev,
1565
1568
struct ib_queue_pair *qp,
1566
struct ib_address_vector *av,
1569
struct ib_address_vector *dest,
1567
1570
struct io_buffer *iobuf ) {
1568
1571
struct hermon *hermon = ib_get_drvdata ( ibdev );
1569
1572
struct hermon_queue_pair *hermon_qp = ib_qp_get_drvdata ( qp );
1594
1597
assert ( qp->type < ( sizeof ( hermon_fill_send_wqe ) /
1595
1598
sizeof ( hermon_fill_send_wqe[0] ) ) );
1596
1599
assert ( hermon_fill_send_wqe[qp->type] != NULL );
1597
opcode = hermon_fill_send_wqe[qp->type] ( ibdev, qp, av, iobuf, wqe );
1600
opcode = hermon_fill_send_wqe[qp->type] ( ibdev, qp, dest, iobuf, wqe );
1599
1602
MLX_FILL_2 ( &wqe->ctrl, 0,
1600
1603
opcode, opcode,
1676
1679
struct ib_work_queue *wq;
1677
1680
struct ib_queue_pair *qp;
1678
1681
struct io_buffer *iobuf;
1679
struct ib_address_vector recv_av;
1682
struct ib_address_vector recv_dest;
1683
struct ib_address_vector recv_source;
1680
1684
struct ib_global_route_header *grh;
1681
struct ib_address_vector *av;
1685
struct ib_address_vector *source;
1682
1686
unsigned int opcode;
1683
1687
unsigned long qpn;
1736
1740
len = MLX_GET ( &cqe->normal, byte_cnt );
1737
1741
assert ( len <= iob_tailroom ( iobuf ) );
1738
1742
iob_put ( iobuf, len );
1739
memset ( &recv_av, 0, sizeof ( recv_av ) );
1743
memset ( &recv_dest, 0, sizeof ( recv_dest ) );
1744
recv_dest.qpn = qpn;
1745
memset ( &recv_source, 0, sizeof ( recv_source ) );
1740
1746
switch ( qp->type ) {
1741
1747
case IB_QPT_SMI:
1742
1748
case IB_QPT_GSI:
1745
1751
grh = iobuf->data;
1746
1752
iob_pull ( iobuf, sizeof ( *grh ) );
1747
1753
/* Construct address vector */
1749
av->qpn = MLX_GET ( &cqe->normal, srq_rqpn );
1750
av->lid = MLX_GET ( &cqe->normal, slid_smac47_32 );
1751
av->sl = MLX_GET ( &cqe->normal, sl );
1752
av->gid_present = MLX_GET ( &cqe->normal, g );
1753
memcpy ( &av->gid, &grh->sgid, sizeof ( av->gid ) );
1754
source = &recv_source;
1755
source->qpn = MLX_GET ( &cqe->normal, srq_rqpn );
1756
source->lid = MLX_GET ( &cqe->normal, slid_smac47_32 );
1757
source->sl = MLX_GET ( &cqe->normal, sl );
1758
recv_dest.gid_present = source->gid_present =
1759
MLX_GET ( &cqe->normal, g );
1760
memcpy ( &recv_dest.gid, &grh->dgid,
1761
sizeof ( recv_dest.gid ) );
1762
memcpy ( &source->gid, &grh->sgid,
1763
sizeof ( source->gid ) );
1755
1765
case IB_QPT_RC:
1758
1768
case IB_QPT_ETH:
1759
1769
/* Construct address vector */
1761
av->vlan_present = MLX_GET ( &cqe->normal, vlan );
1762
av->vlan = MLX_GET ( &cqe->normal, vid );
1770
source = &recv_source;
1771
source->vlan_present = MLX_GET ( &cqe->normal, vlan );
1772
source->vlan = MLX_GET ( &cqe->normal, vid );
1766
1776
return -EINVAL;
1768
1778
/* Hand off to completion handler */
1769
ib_complete_recv ( ibdev, qp, av, iobuf, rc );
1779
ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, rc );
3149
3164
* @v ibdev Infiniband device
3150
3165
* @v qp Queue pair
3151
* @v av Address vector, or NULL
3166
* @v dest Destination address vector, or NULL
3167
* @v source Source address vector, or NULL
3152
3168
* @v iobuf I/O buffer
3153
3169
* @v rc Completion status code
3155
3171
static void hermon_eth_complete_recv ( struct ib_device *ibdev __unused,
3156
3172
struct ib_queue_pair *qp,
3157
struct ib_address_vector *av,
3173
struct ib_address_vector *dest __unused,
3174
struct ib_address_vector *source,
3158
3175
struct io_buffer *iobuf, int rc ) {
3159
3176
struct net_device *netdev = ib_qp_get_ownerdata ( qp );
3160
3177
struct net_device *vlan;
3162
3179
/* Find VLAN device, if applicable */
3163
if ( av->vlan_present ) {
3164
if ( ( vlan = vlan_find ( netdev, av->vlan ) ) != NULL ) {
3180
if ( source->vlan_present ) {
3181
if ( ( vlan = vlan_find ( netdev, source->vlan ) ) != NULL ) {
3166
3183
} else if ( rc == 0 ) {
3224
3241
/* Allocate queue pair */
3225
3242
port->eth_qp = ib_create_qp ( ibdev, IB_QPT_ETH,
3226
3243
HERMON_ETH_NUM_SEND_WQES, port->eth_cq,
3227
HERMON_ETH_NUM_RECV_WQES, port->eth_cq );
3244
HERMON_ETH_NUM_RECV_WQES, port->eth_cq,
3245
&hermon_eth_qp_op );
3228
3246
if ( ! port->eth_qp ) {
3229
3247
DBGC ( hermon, "Hermon %p port %d could not create queue "
3230
3248
"pair\n", hermon, ibdev->port );
3367
3385
&query_port ) ) != 0 ) {
3368
3386
DBGC ( hermon, "Hermon %p port %d could not query port: %s\n",
3369
3387
hermon, ibdev->port, strerror ( rc ) );
3388
goto err_query_port;
3372
3390
mac.dwords[0] = htonl ( MLX_GET ( &query_port, mac_47_32 ) );
3373
3391
mac.dwords[1] = htonl ( MLX_GET ( &query_port, mac_31_0 ) );
3378
3396
if ( ( rc = register_netdev ( netdev ) ) != 0 ) {
3379
3397
DBGC ( hermon, "Hermon %p port %d could not register network "
3380
3398
"device: %s\n", hermon, ibdev->port, strerror ( rc ) );
3399
goto err_register_netdev;
3402
/* Register non-volatile options */
3403
if ( ( rc = register_nvo ( &port->nvo,
3404
netdev_settings ( netdev ) ) ) != 0 ) {
3405
DBGC ( hermon, "Hermon %p port %d could not register non-"
3406
"volatile options: %s\n",
3407
hermon, ibdev->port, strerror ( rc ) );
3408
goto err_register_nvo;
3413
unregister_nvo ( &port->nvo );
3415
unregister_netdev ( netdev );
3416
err_register_netdev:
3806
3841
goto err_set_port_type;
3844
/* Initialise non-volatile storage */
3845
nvs_vpd_init ( &hermon->nvsvpd, pci );
3846
for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
3847
port = &hermon->port[i];
3848
nvs_vpd_nvo_init ( &hermon->nvsvpd,
3849
HERMON_VPD_FIELD ( port->ibdev->port ),
3809
3853
/* Register devices */
3810
3854
for ( i = 0 ; i < hermon->cap.num_ports ; i++ ) {
3811
3855
port = &hermon->port[i];