]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[mirror_ubuntu-artful-kernel.git] / drivers / net / ethernet / mellanox / mlxsw / spectrum_router.c
index e83072da6272c6583ed72cc6546bbed2676580ce..164bd309e92b648cbbbabfab8551efde7ebad4f2 100644 (file)
@@ -382,12 +382,10 @@ static void mlxsw_sp_lpm_init(struct mlxsw_sp *mlxsw_sp)
 
 static struct mlxsw_sp_vr *mlxsw_sp_vr_find_unused(struct mlxsw_sp *mlxsw_sp)
 {
-       struct mlxsw_resources *resources;
        struct mlxsw_sp_vr *vr;
        int i;
 
-       resources = mlxsw_core_resources_get(mlxsw_sp->core);
-       for (i = 0; i < resources->max_virtual_routers; i++) {
+       for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
                vr = &mlxsw_sp->router.vrs[i];
                if (!vr->used)
                        return vr;
@@ -429,14 +427,12 @@ static struct mlxsw_sp_vr *mlxsw_sp_vr_find(struct mlxsw_sp *mlxsw_sp,
                                            u32 tb_id,
                                            enum mlxsw_sp_l3proto proto)
 {
-       struct mlxsw_resources *resources;
        struct mlxsw_sp_vr *vr;
        int i;
 
        tb_id = mlxsw_sp_fix_tb_id(tb_id);
 
-       resources = mlxsw_core_resources_get(mlxsw_sp->core);
-       for (i = 0; i < resources->max_virtual_routers; i++) {
+       for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
                vr = &mlxsw_sp->router.vrs[i];
                if (vr->used && vr->proto == proto && vr->tb_id == tb_id)
                        return vr;
@@ -572,21 +568,20 @@ static void mlxsw_sp_vr_put(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr)
 
 static int mlxsw_sp_vrs_init(struct mlxsw_sp *mlxsw_sp)
 {
-       struct mlxsw_resources *resources;
        struct mlxsw_sp_vr *vr;
+       u64 max_vrs;
        int i;
 
-       resources = mlxsw_core_resources_get(mlxsw_sp->core);
-       if (!resources->max_virtual_routers_valid)
+       if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_VRS))
                return -EIO;
 
-       mlxsw_sp->router.vrs = kcalloc(resources->max_virtual_routers,
-                                      sizeof(struct mlxsw_sp_vr),
+       max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS);
+       mlxsw_sp->router.vrs = kcalloc(max_vrs, sizeof(struct mlxsw_sp_vr),
                                       GFP_KERNEL);
        if (!mlxsw_sp->router.vrs)
                return -ENOMEM;
 
-       for (i = 0; i < resources->max_virtual_routers; i++) {
+       for (i = 0; i < max_vrs; i++) {
                vr = &mlxsw_sp->router.vrs[i];
                vr->id = i;
        }
@@ -1872,14 +1867,15 @@ static int mlxsw_sp_router_set_abort_trap(struct mlxsw_sp *mlxsw_sp)
 
 static void mlxsw_sp_router_fib_flush(struct mlxsw_sp *mlxsw_sp)
 {
-       struct mlxsw_resources *resources;
        struct mlxsw_sp_fib_entry *fib_entry;
        struct mlxsw_sp_fib_entry *tmp;
        struct mlxsw_sp_vr *vr;
        int i;
 
-       resources = mlxsw_core_resources_get(mlxsw_sp->core);
-       for (i = 0; i < resources->max_virtual_routers; i++) {
+       if (mlxsw_sp->router.aborted)
+               return;
+       dev_warn(mlxsw_sp->bus_info->dev, "FIB abort triggered. Note that FIB entries are no longer being offloaded to this device.\n");
+       for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) {
                vr = &mlxsw_sp->router.vrs[i];
 
                if (!vr->used)
@@ -1912,21 +1908,21 @@ static void mlxsw_sp_router_fib4_abort(struct mlxsw_sp *mlxsw_sp)
 
 static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
 {
-       struct mlxsw_resources *resources;
        char rgcr_pl[MLXSW_REG_RGCR_LEN];
+       u64 max_rifs;
        int err;
 
-       resources = mlxsw_core_resources_get(mlxsw_sp->core);
-       if (!resources->max_rif_valid)
+       if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_RIFS))
                return -EIO;
 
-       mlxsw_sp->rifs = kcalloc(resources->max_rif,
-                                sizeof(struct mlxsw_sp_rif *), GFP_KERNEL);
+       max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS);
+       mlxsw_sp->rifs = kcalloc(max_rifs, sizeof(struct mlxsw_sp_rif *),
+                                GFP_KERNEL);
        if (!mlxsw_sp->rifs)
                return -ENOMEM;
 
        mlxsw_reg_rgcr_pack(rgcr_pl, true);
-       mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, resources->max_rif);
+       mlxsw_reg_rgcr_max_router_interfaces_set(rgcr_pl, max_rifs);
        err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rgcr), rgcr_pl);
        if (err)
                goto err_rgcr_fail;
@@ -1940,15 +1936,13 @@ err_rgcr_fail:
 
 static void __mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp)
 {
-       struct mlxsw_resources *resources;
        char rgcr_pl[MLXSW_REG_RGCR_LEN];
        int i;
 
        mlxsw_reg_rgcr_pack(rgcr_pl, false);
        mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rgcr), rgcr_pl);
 
-       resources = mlxsw_core_resources_get(mlxsw_sp->core);
-       for (i = 0; i < resources->max_rif; i++)
+       for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++)
                WARN_ON_ONCE(mlxsw_sp->rifs[i]);
 
        kfree(mlxsw_sp->rifs);
@@ -1996,7 +1990,7 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp)
        if (err)
                goto err_vrs_init;
 
-       err =  mlxsw_sp_neigh_init(mlxsw_sp);
+       err = mlxsw_sp_neigh_init(mlxsw_sp);
        if (err)
                goto err_neigh_init;