mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	RDMA/mana_ib: Enable RoCE on port 1
Set netdev and RoCEv2 flag to enable GID population on port 1. Use GIDs of the master netdev. As mc->ports[] stores slave devices, use a helper to get the master netdev. Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com> Link: https://lore.kernel.org/r/1712738551-22075-5-git-send-email-kotaranov@linux.microsoft.com Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
		
							parent
							
								
									4bda1d5332
								
							
						
					
					
						commit
						8b184e4f1c
					
				
					 2 changed files with 26 additions and 4 deletions
				
			
		| 
						 | 
				
			
			@ -53,6 +53,7 @@ static int mana_ib_probe(struct auxiliary_device *adev,
 | 
			
		|||
{
 | 
			
		||||
	struct mana_adev *madev = container_of(adev, struct mana_adev, adev);
 | 
			
		||||
	struct gdma_dev *mdev = madev->mdev;
 | 
			
		||||
	struct net_device *upper_ndev;
 | 
			
		||||
	struct mana_context *mc;
 | 
			
		||||
	struct mana_ib_dev *dev;
 | 
			
		||||
	int ret;
 | 
			
		||||
| 
						 | 
				
			
			@ -79,6 +80,20 @@ static int mana_ib_probe(struct auxiliary_device *adev,
 | 
			
		|||
	dev->ib_dev.num_comp_vectors = mdev->gdma_context->max_num_queues;
 | 
			
		||||
	dev->ib_dev.dev.parent = mdev->gdma_context->dev;
 | 
			
		||||
 | 
			
		||||
	rcu_read_lock(); /* required to get upper dev */
 | 
			
		||||
	upper_ndev = netdev_master_upper_dev_get_rcu(mc->ports[0]);
 | 
			
		||||
	if (!upper_ndev) {
 | 
			
		||||
		rcu_read_unlock();
 | 
			
		||||
		ibdev_err(&dev->ib_dev, "Failed to get master netdev");
 | 
			
		||||
		goto free_ib_device;
 | 
			
		||||
	}
 | 
			
		||||
	ret = ib_device_set_netdev(&dev->ib_dev, upper_ndev, 1);
 | 
			
		||||
	rcu_read_unlock();
 | 
			
		||||
	if (ret) {
 | 
			
		||||
		ibdev_err(&dev->ib_dev, "Failed to set ib netdev, ret %d", ret);
 | 
			
		||||
		goto free_ib_device;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ret = mana_gd_register_device(&mdev->gdma_context->mana_ib);
 | 
			
		||||
	if (ret) {
 | 
			
		||||
		ibdev_err(&dev->ib_dev, "Failed to register device, ret %d",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -525,11 +525,18 @@ int mana_ib_mmap(struct ib_ucontext *ibcontext, struct vm_area_struct *vma)
 | 
			
		|||
int mana_ib_get_port_immutable(struct ib_device *ibdev, u32 port_num,
 | 
			
		||||
			       struct ib_port_immutable *immutable)
 | 
			
		||||
{
 | 
			
		||||
	/*
 | 
			
		||||
	 * This version only support RAW_PACKET
 | 
			
		||||
	 * other values need to be filled for other types
 | 
			
		||||
	 */
 | 
			
		||||
	struct ib_port_attr attr;
 | 
			
		||||
	int err;
 | 
			
		||||
 | 
			
		||||
	err = ib_query_port(ibdev, port_num, &attr);
 | 
			
		||||
	if (err)
 | 
			
		||||
		return err;
 | 
			
		||||
 | 
			
		||||
	immutable->pkey_tbl_len = attr.pkey_tbl_len;
 | 
			
		||||
	immutable->gid_tbl_len = attr.gid_tbl_len;
 | 
			
		||||
	immutable->core_cap_flags = RDMA_CORE_PORT_RAW_PACKET;
 | 
			
		||||
	if (port_num == 1)
 | 
			
		||||
		immutable->core_cap_flags |= RDMA_CORE_PORT_IBA_ROCE_UDP_ENCAP;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue