The Virtual Customer Premises Equipment (vCPE) technology has recently emerged to reduce telecom operators' OPEX and CAPEX. It evolved from Network Function Virtualization (NFV) and Software Defined Networking (SDN) technologies. This paper proposes a flexible vCPE framework to enable dynamic chaining of Virtual Network Functions (VNF) by using Programmable Protocol-independent Packet Processors (P4) switches. It can obtain a much better packet processing performance compared to the pure software vCPE solution. The OpenFlow switch provides similar hardware acceleration, but it executes the flow tables in a fixed order, and it is not possible to skip the flow tables, which are not subscribed to by a customer. However, P4, the domain-specific language used to describe how to process packets on a data plane (DP), gives more flexibility than the OpenFlow. It provides a way to avoid the fixed flow table execution order and can introduce a new service on the fly. Our flexible vCPE framework can be achieved by the synergies between an NFV controller on the cloud and a P4 switch at the edge. In this paper, an Open Network Operating System (ONOS) controller with P4Runtime is used as a VNF control plane and a P4 Behavioral Model (BMv2) software switch is used as a DP. Finally, dynamic function chaining is realized using three possible implementations, viz. multi-instance, clone, and resubmit. P4 language is used for the implementations. Experimental results show that a multi-instance based solution is better than a resubmit and clone.