Drop using BNG attachment IDs in favor or dynamically allocated line IDs

The current implementation of BngProgrammable for fabric.p4 uses
attachment IDs as line IDs, thus forcing apps such as bngc to be aware
of such implementation detail and to manage the allocation of such IDs.
Unfortunately, allocation of IDs is dependent on the device (P4 program)
implementation (e.g., line counter size), and so it should not be left
to apps.

This patch removes the need for attachment IDs at all and instead relies
on a driver-level service to dynamically allocate line IDs based on the
attachment attributes (currently s-tag, c-tag, mac address).

The current implementation of the allocation logic is a trivial one,
i.e. non-distributed and non-optimized.

Change-Id: Ie960936ee750cf565b8de41370085ecf9d49e931
(cherry picked from commit 6aa2a6ea743e8104ee3c62acb7d26acbd1452614)
diff --git a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricCapabilities.java b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricCapabilities.java
index 6def74f..19b3206 100644
--- a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricCapabilities.java
+++ b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricCapabilities.java
@@ -72,7 +72,7 @@
             }
         } catch (IOException e) {
             log.error("Unable to read CPU port file of {}: {}",
-                      pipeconf.id(), e.getMessage());
+                    pipeconf.id(), e.getMessage());
             return Optional.empty();
         }
     }
@@ -86,4 +86,31 @@
         }
         return false;
     }
+
+    /**
+     * Returns true if the pipeconf supports BNG user plane capabilities, false
+     * otherwise.
+     *
+     * @return boolean
+     */
+    public boolean supportBng() {
+        return pipeconf.pipelineModel()
+                .counter(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_C_LINE_RX)
+                .isPresent();
+    }
+
+    /**
+     * Returns the maximum number of BNG lines supported, or 0 if this pipeconf
+     * does not support BNG capabilities.
+     *
+     * @return maximum number of lines supported
+     */
+    public long bngMaxLineCount() {
+        if (!supportBng()) {
+            return 0;
+        }
+        return pipeconf.pipelineModel()
+                .counter(FabricConstants.FABRIC_INGRESS_BNG_INGRESS_DOWNSTREAM_C_LINE_RX)
+                .orElseThrow().size();
+    }
 }